mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
mock datastore tests (#562)
This commit is contained in:
committed by
Travis Reeder
parent
947fedb194
commit
17e18d872b
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user