Add test fixture to check for warnings
This commit is contained in:
parent
5fa24a0128
commit
048af6e237
|
@ -859,7 +859,6 @@ func (c *Config) Validate() tfdiags.Diagnostics {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -862,3 +862,22 @@ func TestConfigModuleProviders(t *testing.T) {
|
|||
t.Fatalf("exptected providers %#v, got providers %#v", expected, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateOutputErrorWarnings(t *testing.T) {
|
||||
// TODO: remove this in 0.12
|
||||
c := testConfig(t, "output-warnings")
|
||||
|
||||
diags := c.Validate()
|
||||
if diags.HasErrors() {
|
||||
t.Fatal("config should not have errors:", diags)
|
||||
}
|
||||
if len(diags) != 2 {
|
||||
t.Fatalf("should have 2 warnings, got %d:\n%s", len(diags), diags)
|
||||
}
|
||||
|
||||
// this fixture has no explicit count, and should have no warning
|
||||
c = testConfig(t, "output-no-warnings")
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Fatal("config should have no warnings or errors")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
resource "test_instance" "foo" {
|
||||
}
|
||||
|
||||
output "foo_id" {
|
||||
value = "${test_instance.foo.id}"
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
locals {
|
||||
"count" = 1
|
||||
}
|
||||
|
||||
resource "test_instance" "foo" {
|
||||
count = "${local.count}"
|
||||
}
|
||||
|
||||
output "foo_id" {
|
||||
value = "${test_instance.foo.id}"
|
||||
}
|
||||
|
||||
variable "condition" {
|
||||
default = "true"
|
||||
}
|
||||
|
||||
resource "test_instance" "bar" {
|
||||
count = "${var.condition ? 1 : 0}"
|
||||
}
|
||||
|
||||
|
||||
output "bar_id" {
|
||||
value = "${test_instance.bar.id}"
|
||||
}
|
Loading…
Reference in New Issue