Adds key existence check to config equality (#1204)

The config equality test doesn't check that keys exist between config
maps. Meaning that when two maps, both with a single, yet differing
key, with the lefts value being "", the default string, are compared they are
considered equal.

This change uses the two value assignment version of the map get,
allowing it to test for key existence.
This commit is contained in:
Tom Coupland
2018-09-12 07:27:32 +01:00
committed by GitHub
parent 8df7cec8f5
commit c4dcd96adb

View File

@@ -20,8 +20,7 @@ func (c1 Config) Equals(c2 Config) bool {
return false
}
for k1, v1 := range c1 {
v2, _ := c2[k1]
if v1 != v2 {
if v2, ok := c2[k1]; !ok || v1 != v2 {
return false
}
}