mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Implement updates to testing framework based on recent feedback
This commit is contained in:
@@ -3,6 +3,8 @@ variables {
|
||||
}
|
||||
|
||||
run "test" {
|
||||
command = plan
|
||||
|
||||
expect_failures = [
|
||||
var.input
|
||||
]
|
||||
|
||||
@@ -3,6 +3,9 @@ variables {
|
||||
}
|
||||
|
||||
run "test" {
|
||||
|
||||
command = plan
|
||||
|
||||
expect_failures = [
|
||||
output.output
|
||||
]
|
||||
|
||||
@@ -3,6 +3,8 @@ variables {
|
||||
}
|
||||
|
||||
run "test" {
|
||||
command = plan
|
||||
|
||||
expect_failures = [
|
||||
test_resource.resource
|
||||
]
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
run "test" {
|
||||
variables {
|
||||
input = "Hello, world!"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = test_resource.resource.value == "Hello, world!"
|
||||
error_message = "wrong condition"
|
||||
|
||||
9
internal/command/testdata/test/only_modules/example/main.tf
vendored
Normal file
9
internal/command/testdata/test/only_modules/example/main.tf
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
variable "input" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "test_resource" "module_resource" {
|
||||
id = "df6h8as9"
|
||||
value = var.input
|
||||
}
|
||||
9
internal/command/testdata/test/only_modules/main.tf
vendored
Normal file
9
internal/command/testdata/test/only_modules/main.tf
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
variable "input" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "test_resource" "resource" {
|
||||
id = "598318e0"
|
||||
value = var.input
|
||||
}
|
||||
23
internal/command/testdata/test/only_modules/main.tftest.hcl
vendored
Normal file
23
internal/command/testdata/test/only_modules/main.tftest.hcl
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# This is an example test file from a use case requested by a user. We only
|
||||
# refer to alternate modules and not the main configuration. This means we
|
||||
# shouldn't have to provide any data for the main configuration.
|
||||
|
||||
run "first" {
|
||||
module {
|
||||
source = "./example"
|
||||
}
|
||||
|
||||
variables {
|
||||
input = "start"
|
||||
}
|
||||
}
|
||||
|
||||
run "second" {
|
||||
module {
|
||||
source = "./example"
|
||||
}
|
||||
|
||||
variables {
|
||||
input = "update"
|
||||
}
|
||||
}
|
||||
15
internal/command/testdata/test/partial_updates/main.tf
vendored
Normal file
15
internal/command/testdata/test/partial_updates/main.tf
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
resource "test_resource" "resource" {}
|
||||
|
||||
locals {
|
||||
follow = {
|
||||
(test_resource.resource.id): "follow"
|
||||
}
|
||||
}
|
||||
|
||||
resource "test_resource" "follow" {
|
||||
for_each = local.follow
|
||||
|
||||
id = each.key
|
||||
value = each.value
|
||||
}
|
||||
10
internal/command/testdata/test/partial_updates/main.tftest.hcl
vendored
Normal file
10
internal/command/testdata/test/partial_updates/main.tftest.hcl
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
run "first" {
|
||||
plan_options {
|
||||
target = [
|
||||
test_resource.resource,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
run "second" {}
|
||||
9
internal/command/testdata/test/state_propagation/example/main.tf
vendored
Normal file
9
internal/command/testdata/test/state_propagation/example/main.tf
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
variable "input" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "test_resource" "module_resource" {
|
||||
id = "df6h8as9"
|
||||
value = var.input
|
||||
}
|
||||
9
internal/command/testdata/test/state_propagation/main.tf
vendored
Normal file
9
internal/command/testdata/test/state_propagation/main.tf
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
variable "input" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "test_resource" "resource" {
|
||||
id = "598318e0"
|
||||
value = var.input
|
||||
}
|
||||
54
internal/command/testdata/test/state_propagation/main.tftest.hcl
vendored
Normal file
54
internal/command/testdata/test/state_propagation/main.tftest.hcl
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# Our test will run this in verbose mode and we should see the plan output for
|
||||
# the second run block showing the resource being updated as the state should
|
||||
# be propagated from the first one to the second one.
|
||||
#
|
||||
# We also interweave alternate modules to test the handling of multiple states
|
||||
# within the file.
|
||||
|
||||
run "initial_apply_example" {
|
||||
module {
|
||||
source = "./example"
|
||||
}
|
||||
|
||||
variables {
|
||||
input = "start"
|
||||
}
|
||||
}
|
||||
|
||||
run "initial_apply" {
|
||||
variables {
|
||||
input = "start"
|
||||
}
|
||||
}
|
||||
|
||||
run "plan_second_example" {
|
||||
command = plan
|
||||
|
||||
module {
|
||||
source = "./second_example"
|
||||
}
|
||||
|
||||
variables {
|
||||
input = "start"
|
||||
}
|
||||
}
|
||||
|
||||
run "plan_update" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
input = "update"
|
||||
}
|
||||
}
|
||||
|
||||
run "plan_update_example" {
|
||||
command = plan
|
||||
|
||||
module {
|
||||
source = "./example"
|
||||
}
|
||||
|
||||
variables {
|
||||
input = "update"
|
||||
}
|
||||
}
|
||||
9
internal/command/testdata/test/state_propagation/second_example/main.tf
vendored
Normal file
9
internal/command/testdata/test/state_propagation/second_example/main.tf
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
variable "input" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "test_resource" "second_module_resource" {
|
||||
id = "b6a1d8cb"
|
||||
value = var.input
|
||||
}
|
||||
Reference in New Issue
Block a user