mirror of
https://github.com/hashicorp/terraform.git
synced 2026-06-09 00:42:48 -04:00
test: Add E2E test coverage for inspecting a plan file using the terraform show command (#38020)
Some checks failed
build / Determine intended Terraform version (push) Has been cancelled
build / Determine Go toolchain version (push) Has been cancelled
Quick Checks / Unit Tests (push) Has been cancelled
Quick Checks / Race Tests (push) Has been cancelled
Quick Checks / End-to-end Tests (push) Has been cancelled
Quick Checks / Code Consistency Checks (push) Has been cancelled
build / Generate release metadata (push) Has been cancelled
build / Build for freebsd_386 (push) Has been cancelled
build / Build for linux_386 (push) Has been cancelled
build / Build for openbsd_386 (push) Has been cancelled
build / Build for windows_386 (push) Has been cancelled
build / Build for darwin_amd64 (push) Has been cancelled
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
Some checks failed
build / Determine intended Terraform version (push) Has been cancelled
build / Determine Go toolchain version (push) Has been cancelled
Quick Checks / Unit Tests (push) Has been cancelled
Quick Checks / Race Tests (push) Has been cancelled
Quick Checks / End-to-end Tests (push) Has been cancelled
Quick Checks / Code Consistency Checks (push) Has been cancelled
build / Generate release metadata (push) Has been cancelled
build / Build for freebsd_386 (push) Has been cancelled
build / Build for linux_386 (push) Has been cancelled
build / Build for openbsd_386 (push) Has been cancelled
build / Build for windows_386 (push) Has been cancelled
build / Build for darwin_amd64 (push) Has been cancelled
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
This commit is contained in:
parent
13cccebef0
commit
193867f060
3 changed files with 42 additions and 6 deletions
|
|
@ -276,7 +276,7 @@ func TestPrimary_stateStore_outputCmd(t *testing.T) {
|
|||
// Tests using the `terraform show` command in combination with pluggable state storage
|
||||
// > `terraform show`
|
||||
// > `terraform show <path-to-state-file>`
|
||||
// > `terraform show <path-to-plan-file>` // TODO
|
||||
// > `terraform show <path-to-plan-file>`
|
||||
func TestPrimary_stateStore_showCmd(t *testing.T) {
|
||||
|
||||
if !canRunGoBuild {
|
||||
|
|
@ -353,7 +353,44 @@ greeting = "hello world"
|
|||
t.Errorf("wrong result, diff:\n%s", diff)
|
||||
}
|
||||
|
||||
// TODO(SarahFrench/radeksimko): Show plan file: terraform show <path to plan file>
|
||||
//// Show state: terraform show <path to plan file>
|
||||
|
||||
// 1. Create a plan file via plan command
|
||||
newOutput := `output "replacement" {
|
||||
value = resource.terraform_data.my-data.output
|
||||
}`
|
||||
if err := os.WriteFile(filepath.Join(tf.WorkDir(), "outputs.tf"), []byte(newOutput), 0644); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
planFile := "tfplan"
|
||||
stdout, stderr, err = tf.Run("plan", fmt.Sprintf("-out=%s", planFile), "-no-color")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %s\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
expectedMsg = "Changes to Outputs"
|
||||
if !strings.Contains(stdout, expectedMsg) {
|
||||
t.Errorf("wrong result, expected the plan command to create a plan file but that hasn't happened, got:\n%s",
|
||||
stdout,
|
||||
)
|
||||
}
|
||||
|
||||
// 2. Inspect plan file
|
||||
stdout, stderr, err = tf.Run("show", planFile, "-no-color")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %s\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
expectedMsg = `
|
||||
Changes to Outputs:
|
||||
- greeting = "hello world" -> null
|
||||
+ replacement = "hello world"
|
||||
|
||||
You can apply this plan to save these new output values to the Terraform
|
||||
state, without changing any real infrastructure.
|
||||
`
|
||||
if diff := cmp.Diff(stdout, expectedMsg); diff != "" {
|
||||
t.Errorf("wrong result, diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
// Tests using the `terraform provider` subcommands in combination with pluggable state storage:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,3 @@ variable "name" {
|
|||
resource "terraform_data" "my-data" {
|
||||
input = "hello ${var.name}"
|
||||
}
|
||||
|
||||
output "greeting" {
|
||||
value = resource.terraform_data.my-data.output
|
||||
}
|
||||
|
|
|
|||
3
internal/command/e2etest/testdata/initialized-directory-with-state-store-fs/outputs.tf
vendored
Normal file
3
internal/command/e2etest/testdata/initialized-directory-with-state-store-fs/outputs.tf
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
output "greeting" {
|
||||
value = resource.terraform_data.my-data.output
|
||||
}
|
||||
Loading…
Reference in a new issue