core: failing test for a bad module cycle

passing output of one module into input of the following module results
in a cycle
This commit is contained in:
Paul Hinze 2015-05-04 15:43:23 -05:00
parent 13f3daa3b3
commit c3ce23c7b4
4 changed files with 37 additions and 0 deletions

View File

@ -2443,6 +2443,26 @@ func TestContext2Validate_moduleBadResource(t *testing.T) {
}
}
func TestContext2Validate_moduleDepsShouldNotCycle(t *testing.T) {
m := testModule(t, "validate-module-deps-cycle")
p := testProvider("aws")
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
w, e := ctx.Validate()
if len(w) > 0 {
t.Fatalf("expected no warnings, got: %s", w)
}
if len(e) > 0 {
t.Fatalf("expected no errors, got: %s", e)
}
}
func TestContext2Validate_moduleProviderInherit(t *testing.T) {
m := testModule(t, "validate-module-pc-inherit")
p := testProvider("aws")

View File

@ -0,0 +1,5 @@
resource "aws_instance" "a" { }
output "output" {
value = "${aws_instance.a.id}"
}

View File

@ -0,0 +1,4 @@
variable "input" {}
resource "aws_instance" "b" {
name = "${var.input}"
}

View File

@ -0,0 +1,8 @@
module "a" {
source = "./a"
}
module "b" {
source = "./b"
input = "${module.a.output}"
}