Merge 552b84041e
into b68feb9c59
This commit is contained in:
commit
5caf3d7c5d
2 changed files with 24 additions and 1 deletions
|
@ -51,7 +51,7 @@ func mergeLocationAnnotations(loc *ingress.Location, anns map[string]interface{}
|
|||
loc.Denied = anns[DeniedKeyName].(error)
|
||||
}
|
||||
delete(anns, DeniedKeyName)
|
||||
err := mergo.Map(loc, anns)
|
||||
err := mergo.MapWithOverwrite(loc, anns)
|
||||
if err != nil {
|
||||
glog.Errorf("unexpected error merging extracted annotations in location type: %v", err)
|
||||
}
|
||||
|
|
|
@ -82,6 +82,29 @@ func TestMergeLocationAnnotations(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestMergeLocationAnnotationsExisting(t *testing.T) {
|
||||
loc := ingress.Location{
|
||||
IsDefBackend: true,
|
||||
Proxy: proxy.Configuration{ReadTimeout: 60},
|
||||
}
|
||||
annotations := map[string]interface{}{
|
||||
"Proxy": proxy.Configuration{ReadTimeout: 999},
|
||||
}
|
||||
|
||||
mergeLocationAnnotations(&loc, annotations)
|
||||
|
||||
// Existing value should be unmodified.
|
||||
if got, want := loc.IsDefBackend, true; got != want {
|
||||
t.Errorf("loc.IsDefBackend = %v, want %v", got, want)
|
||||
}
|
||||
|
||||
// New value from annotation should be updated.
|
||||
if got, want := loc.Proxy.ReadTimeout, annotations["Proxy"].(proxy.Configuration).ReadTimeout; got != want {
|
||||
t.Errorf("loc.Proxy.ReadTimeout = %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestIntInSlice(t *testing.T) {
|
||||
fooTests := []struct {
|
||||
i int
|
||||
|
|
Loading…
Reference in a new issue