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:
parent
a3639b6156
commit
37c4edd5e7
|
@ -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")
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
resource "aws_instance" "web" {
|
||||||
|
foo = "${aws_instance.web.*.foo}"
|
||||||
|
count = 4
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
resource "aws_instance" "web" {
|
||||||
|
foo = "${aws_instance.web.0.foo}"
|
||||||
|
count = 4
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
resource "aws_instance" "web" {
|
||||||
|
foo = "${aws_instance.web.foo}"
|
||||||
|
}
|
Loading…
Reference in New Issue