diff --git a/config/raw_config_test.go b/config/raw_config_test.go index d6901d3c45..e718ca9943 100644 --- a/config/raw_config_test.go +++ b/config/raw_config_test.go @@ -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") + } +}