add tests
This commit is contained in:
parent
bb22cfcf34
commit
fcf16315a3
@ -2,6 +2,7 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -27,6 +28,15 @@ func outputCommand(t *testing.T, m Meta) (string, string) {
|
|||||||
return out.String(), err.String()
|
return out.String(), err.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testFixtureContent(n ...string) string {
|
||||||
|
path := filepath.Join(append([]string{fixturesDir}, n...)...)
|
||||||
|
b, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
|
||||||
func testFixture(n ...string) string {
|
func testFixture(n ...string) string {
|
||||||
paths := []string{fixturesDir}
|
paths := []string{fixturesDir}
|
||||||
paths = append(paths, n...)
|
paths = append(paths, n...)
|
||||||
|
@ -153,6 +153,13 @@ Note: If your build names contain user variables or template
|
|||||||
functions such as 'timestamp', these are processed at build time,
|
functions such as 'timestamp', these are processed at build time,
|
||||||
and therefore only show in their raw form here.
|
and therefore only show in their raw form here.
|
||||||
`},
|
`},
|
||||||
|
{
|
||||||
|
[]string{
|
||||||
|
"inspect", filepath.Join(testFixture("hcl-inspect-with-sensitive-vars")),
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
testFixtureContent("hcl-inspect-with-sensitive-vars", "expected-output.txt"),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tc {
|
for _, tc := range tc {
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
Packer Inspect: HCL2 mode
|
||||||
|
|
||||||
|
> input-variables:
|
||||||
|
|
||||||
|
var.not_sensitive: "I am soooo not sensitive"
|
||||||
|
var.not_sensitive_unknown: "<unknown>"
|
||||||
|
var.sensitive: "<sensitive>"
|
||||||
|
var.sensitive_array: "[\n \"<sensitive>\",\n \"<sensitive>\",\n]"
|
||||||
|
var.sensitive_tags: "{\n \"first_key\" = \"<sensitive>\"\n \"second_key\" = \"<sensitive>\"\n}"
|
||||||
|
var.sensitive_unknown: "<unknown>"
|
||||||
|
|
||||||
|
> local-variables:
|
||||||
|
|
||||||
|
|
||||||
|
> builds:
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
variable "not_sensitive" {
|
||||||
|
default = "I am soooo not sensitive"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "not_sensitive_unknown" {
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "sensitive" {
|
||||||
|
default = "I am soooo sensitive"
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "sensitive_array" {
|
||||||
|
default = ["Im supersensitive", "me too !!!!"]
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "sensitive_tags" {
|
||||||
|
default = {
|
||||||
|
first_key = "this-is-mega-sensitive"
|
||||||
|
second_key = "this-is-also-sensitive"
|
||||||
|
}
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "sensitive_unknown" {
|
||||||
|
sensitive = true
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user