Implement updates to testing framework based on recent feedback

This commit is contained in:
Liam Cervante
2023-08-07 14:42:07 +02:00
parent 3cce200d0e
commit 126f34e4e8
16 changed files with 822 additions and 379 deletions

View File

@@ -3,6 +3,8 @@ variables {
}
run "test" {
command = plan
expect_failures = [
var.input
]

View File

@@ -3,6 +3,9 @@ variables {
}
run "test" {
command = plan
expect_failures = [
output.output
]

View File

@@ -3,6 +3,8 @@ variables {
}
run "test" {
command = plan
expect_failures = [
test_resource.resource
]

View File

@@ -1,8 +1,4 @@
run "test" {
variables {
input = "Hello, world!"
}
assert {
condition = test_resource.resource.value == "Hello, world!"
error_message = "wrong condition"

View File

@@ -0,0 +1,9 @@
variable "input" {
type = string
}
resource "test_resource" "module_resource" {
id = "df6h8as9"
value = var.input
}

View File

@@ -0,0 +1,9 @@
variable "input" {
type = string
}
resource "test_resource" "resource" {
id = "598318e0"
value = var.input
}

View 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"
}
}

View 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
}

View File

@@ -0,0 +1,10 @@
run "first" {
plan_options {
target = [
test_resource.resource,
]
}
}
run "second" {}

View File

@@ -0,0 +1,9 @@
variable "input" {
type = string
}
resource "test_resource" "module_resource" {
id = "df6h8as9"
value = var.input
}

View File

@@ -0,0 +1,9 @@
variable "input" {
type = string
}
resource "test_resource" "resource" {
id = "598318e0"
value = var.input
}

View 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"
}
}

View File

@@ -0,0 +1,9 @@
variable "input" {
type = string
}
resource "test_resource" "second_module_resource" {
id = "b6a1d8cb"
value = var.input
}