mock datastore tests (#562)

This commit is contained in:
Jordan Krage
2017-03-02 00:04:04 -06:00
committed by Travis Reeder
parent 947fedb194
commit 17e18d872b
5 changed files with 97 additions and 54 deletions

View File

@@ -53,6 +53,23 @@ func (a *App) Validate() error {
return nil
}
func (a *App) Clone() *App {
var c App
c.Name = a.Name
if a.Routes != nil {
for i := range a.Routes {
c.Routes = append(c.Routes, a.Routes[i].Clone())
}
}
if a.Config != nil {
c.Config = make(Config)
for k, v := range a.Config {
c.Config[k] = v
}
}
return &c
}
// UpdateConfig adds entries from patch to a.Config, and removes entries with empty values.
func (a *App) UpdateConfig(patch Config) {
if patch != nil {

View File

@@ -125,6 +125,14 @@ func (r *Route) Validate() error {
return nil
}
func (r *Route) Clone() *Route {
var clone Route
clone.AppName = r.AppName
clone.Path = r.Path
clone.Update(r)
return &clone
}
// Update updates fields in r with non-zero field values from new.
// 0-length slice Header values, and empty-string Config values trigger removal of map entry.
func (r *Route) Update(new *Route) {