From 94674fe93c8e783f31c1b0a9df4cbfd973385890 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 2 Sep 2016 14:45:21 -0400 Subject: [PATCH] Add a test load of a data source with count --- config/config_test.go | 17 +++++++++++++++++ config/test-fixtures/data-count/main.tf | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 config/test-fixtures/data-count/main.tf diff --git a/config/config_test.go b/config/config_test.go index 92a6ea890..084a301ee 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -552,3 +552,20 @@ func testConfig(t *testing.T, name string) *Config { return c } + +func TestConfigDataCount(t *testing.T) { + c := testConfig(t, "data-count") + actual, err := c.Resources[0].Count() + if err != nil { + t.Fatalf("err: %s", err) + } + if actual != 5 { + t.Fatalf("bad: %#v", actual) + } + + // we need to make sure "count" has been removed from the RawConfig, since + // it's not a real key and won't validate. + if _, ok := c.Resources[0].RawConfig.Raw["count"]; ok { + t.Fatal("count key still exists in RawConfig") + } +} diff --git a/config/test-fixtures/data-count/main.tf b/config/test-fixtures/data-count/main.tf new file mode 100644 index 000000000..e49a065df --- /dev/null +++ b/config/test-fixtures/data-count/main.tf @@ -0,0 +1,3 @@ +data "foo" "bar" { + count = 5 +}