terraform: test cases around self-referencing variables

This includes cases of multi-counts.

/cc @armon - Looks like this was a non-issue. Terraform already errors
on this.
This commit is contained in:
Mitchell Hashimoto 2014-07-26 15:02:23 -07:00
parent a3639b6156
commit 37c4edd5e7
4 changed files with 68 additions and 0 deletions

View File

@ -249,6 +249,63 @@ func TestContextValidate_provisionerConfig_good(t *testing.T) {
} }
} }
func TestContextValidate_selfRef(t *testing.T) {
p := testProvider("aws")
config := testConfig(t, "validate-self-ref")
c := testContext(t, &ContextOpts{
Config: config,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
w, e := c.Validate()
if len(w) > 0 {
t.Fatalf("bad: %#v", w)
}
if len(e) == 0 {
t.Fatalf("bad: %#v", e)
}
}
func TestContextValidate_selfRefMulti(t *testing.T) {
p := testProvider("aws")
config := testConfig(t, "validate-self-ref-multi")
c := testContext(t, &ContextOpts{
Config: config,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
w, e := c.Validate()
if len(w) > 0 {
t.Fatalf("bad: %#v", w)
}
if len(e) == 0 {
t.Fatalf("bad: %#v", e)
}
}
func TestContextValidate_selfRefMultiAll(t *testing.T) {
p := testProvider("aws")
config := testConfig(t, "validate-self-ref-multi-all")
c := testContext(t, &ContextOpts{
Config: config,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
w, e := c.Validate()
if len(w) > 0 {
t.Fatalf("bad: %#v", w)
}
if len(e) == 0 {
t.Fatalf("bad: %#v", e)
}
}
func TestContextApply(t *testing.T) { func TestContextApply(t *testing.T) {
c := testConfig(t, "apply-good") c := testConfig(t, "apply-good")
p := testProvider("aws") p := testProvider("aws")

View File

@ -0,0 +1,4 @@
resource "aws_instance" "web" {
foo = "${aws_instance.web.*.foo}"
count = 4
}

View File

@ -0,0 +1,4 @@
resource "aws_instance" "web" {
foo = "${aws_instance.web.0.foo}"
count = 4
}

View File

@ -0,0 +1,3 @@
resource "aws_instance" "web" {
foo = "${aws_instance.web.foo}"
}