mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
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)
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
6
config/test-fixtures/output-no-warnings/main.tf
Normal file
6
config/test-fixtures/output-no-warnings/main.tf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
resource "test_instance" "foo" {
|
||||||
|
}
|
||||||
|
|
||||||
|
output "foo_id" {
|
||||||
|
value = "${test_instance.foo.id}"
|
||||||
|
}
|
24
config/test-fixtures/output-warnings/main.tf
Normal file
24
config/test-fixtures/output-warnings/main.tf
Normal file
@ -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
Block a user