From bbca28a0ef3be43104ab71b25b9641d8ef530fd5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 12 Jun 2014 17:26:05 -0700 Subject: [PATCH] config: test double interpolating --- config/raw_config_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/config/raw_config_test.go b/config/raw_config_test.go index 6e318a8f1..bae1799c7 100644 --- a/config/raw_config_test.go +++ b/config/raw_config_test.go @@ -48,6 +48,45 @@ func TestRawConfig(t *testing.T) { } } +func TestRawConfig_double(t *testing.T) { + raw := map[string]interface{}{ + "foo": "${var.bar}", + } + + rc, err := NewRawConfig(raw) + if err != nil { + t.Fatalf("err: %s", err) + } + + vars := map[string]string{"var.bar": "baz"} + if err := rc.Interpolate(vars); err != nil { + t.Fatalf("err: %s", err) + } + + actual := rc.Config() + expected := map[string]interface{}{ + "foo": "baz", + } + + if !reflect.DeepEqual(actual, expected) { + t.Fatalf("bad: %#v", actual) + } + + vars = map[string]string{"var.bar": "what"} + if err := rc.Interpolate(vars); err != nil { + t.Fatalf("err: %s", err) + } + + actual = rc.Config() + expected = map[string]interface{}{ + "foo": "what", + } + + if !reflect.DeepEqual(actual, expected) { + t.Fatalf("bad: %#v", actual) + } +} + func TestRawConfig_unknown(t *testing.T) { raw := map[string]interface{}{ "foo": "${var.bar}",