config: test to make sure that cycles are properly detected

This commit is contained in:
Mitchell Hashimoto 2014-06-05 12:53:59 -07:00
parent d2c3db552a
commit 867f6b3691
2 changed files with 30 additions and 0 deletions

View File

@ -29,6 +29,18 @@ func TestConfigResourceGraph(t *testing.T) {
} }
} }
func TestConfigResourceGraph_cycle(t *testing.T) {
c, err := Load(filepath.Join(fixtureDir, "resource_graph_cycle.tf"))
if err != nil {
t.Fatalf("err: %s", err)
}
graph := c.ResourceGraph()
if err := graph.Validate(); err == nil {
t.Fatal("graph should be invalid")
}
}
func TestNewResourceVariable(t *testing.T) { func TestNewResourceVariable(t *testing.T) {
v, err := NewResourceVariable("foo.bar.baz") v, err := NewResourceVariable("foo.bar.baz")
if err != nil { if err != nil {

View File

@ -0,0 +1,18 @@
variable "foo" {
default = "bar";
description = "bar";
}
provider "aws" {
foo = "${aws_security_group.firewall.value}"
}
resource "aws_security_group" "firewall" {}
resource "aws_instance" "web" {
ami = "${var.foo}"
security_groups = [
"foo",
"${aws_security_group.firewall.foo}"
]
}