mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
fix: type defaults for variables in tests (#2244)
Signed-off-by: ollevche <ollevche@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e5d26f9a71
commit
32ca523689
@@ -3,3 +3,10 @@ variable "input" {
|
||||
type = string
|
||||
default = "Hello, world!"
|
||||
}
|
||||
|
||||
variable "another_input" {
|
||||
type = object({
|
||||
optional_string = optional(string, "type_default")
|
||||
optional_number = optional(number, 42)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,4 +4,20 @@ run "applies_defaults" {
|
||||
condition = var.input == "Hello, world!"
|
||||
error_message = "should have applied default value"
|
||||
}
|
||||
|
||||
variables {
|
||||
another_input = {
|
||||
optional_string = "Hello, world!"
|
||||
}
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = var.another_input.optional_string == "Hello, world!"
|
||||
error_message = "should have used custom value from test file"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = var.another_input.optional_number == 42
|
||||
error_message = "should have used default type value"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user