From a25f05798465e78353683f74518f13c15506024d Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 1 Sep 2020 13:07:45 +0200 Subject: [PATCH] add tests for unknown values --- command/inspect_test.go | 26 ++++++++++++++++++- .../hcl/inspect/fruit_string.pkr.hcl | 7 +++++ command/test-fixtures/inspect/unset_var.json | 5 ++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 command/test-fixtures/inspect/unset_var.json diff --git a/command/inspect_test.go b/command/inspect_test.go index 52c00009d..73d93b1c2 100644 --- a/command/inspect_test.go +++ b/command/inspect_test.go @@ -69,11 +69,13 @@ local.fruit: "banana" `}, - {[]string{"inspect", "-var=fruit=peach", filepath.Join(testFixture("hcl"), "inspect", "fruit_string.pkr.hcl")}, nil, `Packer Inspect: HCL2 mode + {[]string{"inspect", "-var=fruit=peach", "-var=unknown_string=also_peach", `-var=unknown_unknown="peach_too"`, filepath.Join(testFixture("hcl"), "inspect", "fruit_string.pkr.hcl")}, nil, `Packer Inspect: HCL2 mode > input-variables: var.fruit: "peach" +var.unknown_string: "also_peach" +var.unknown_unknown: "peach_too" > local-variables: @@ -86,6 +88,8 @@ var.fruit: "peach" > input-variables: var.fruit: "peach" +var.unknown_string: "" +var.unknown_unknown: "" > local-variables: @@ -121,6 +125,26 @@ Use it at will. manifest shell-local +`}, + {[]string{"inspect", filepath.Join(testFixture("inspect"), "unset_var.json")}, nil, `Packer Inspect: JSON mode +Required variables: + + something + +Optional variables and their defaults: + + +Builders: + + + +Provisioners: + + + +Note: If your build names contain user variables or template +functions such as 'timestamp', these are processed at build time, +and therefore only show in their raw form here. `}, } diff --git a/command/test-fixtures/hcl/inspect/fruit_string.pkr.hcl b/command/test-fixtures/hcl/inspect/fruit_string.pkr.hcl index 3140d12e0..fb285b422 100644 --- a/command/test-fixtures/hcl/inspect/fruit_string.pkr.hcl +++ b/command/test-fixtures/hcl/inspect/fruit_string.pkr.hcl @@ -3,3 +3,10 @@ variable "fruit" { type = string default = "banana" } + +variable "unknown_string" { + type = string +} + +variable "unknown_unknown" { +} diff --git a/command/test-fixtures/inspect/unset_var.json b/command/test-fixtures/inspect/unset_var.json new file mode 100644 index 000000000..f2d2471a5 --- /dev/null +++ b/command/test-fixtures/inspect/unset_var.json @@ -0,0 +1,5 @@ +{ + "variables": { + "something": null + } +}