Add test for RawMap
Ensure that RawMap() returns an identical copy, and not a reference to the original map.
This commit is contained in:
parent
632c16c212
commit
14138fc449
|
@ -342,3 +342,27 @@ func TestRawConfig_implGob(t *testing.T) {
|
|||
var _ gob.GobDecoder = new(RawConfig)
|
||||
var _ gob.GobEncoder = new(RawConfig)
|
||||
}
|
||||
|
||||
// verify that RawMap returns a identical copy
|
||||
func TestNewRawConfig_rawMap(t *testing.T) {
|
||||
raw := map[string]interface{}{
|
||||
"foo": "${var.bar}",
|
||||
"bar": `${file("boom.txt")}`,
|
||||
}
|
||||
|
||||
rc, err := NewRawConfig(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
rawCopy := rc.RawMap()
|
||||
if !reflect.DeepEqual(raw, rawCopy) {
|
||||
t.Fatalf("bad: %#v", rawCopy)
|
||||
}
|
||||
|
||||
// make sure they aren't the same map
|
||||
raw["test"] = "value"
|
||||
if reflect.DeepEqual(raw, rawCopy) {
|
||||
t.Fatal("RawMap() didn't return a copy")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue