mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-08 16:22:15 -04:00
datasource/http: change Outputs->ExpectedOutputs
The acceptance tests for the HTTP datasource had a `Outputs` attribute for checking the output of the command for a specific regexp pattern. As pointed out, given the expectative nature of the attribute, naming it `Outputs` did not make the intent clear, so we rename it to `ExpectedOutputs` with this commit.
This commit is contained in:
parent
c470395b7a
commit
35d14902b0
1 changed files with 9 additions and 9 deletions
|
|
@ -29,16 +29,16 @@ var testDatasourceInvalidMethod string
|
|||
|
||||
func TestHttpDataSource(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
Path string
|
||||
Error bool
|
||||
Outputs map[string]string
|
||||
Name string
|
||||
Path string
|
||||
Error bool
|
||||
ExpectedOutputs map[string]string
|
||||
}{
|
||||
{
|
||||
Name: "basic_test",
|
||||
Path: testDatasourceBasic,
|
||||
Error: false,
|
||||
Outputs: map[string]string{
|
||||
ExpectedOutputs: map[string]string{
|
||||
"url": "url is https://www.packer.io/",
|
||||
// Check that body is not empty
|
||||
"body": "body is true",
|
||||
|
|
@ -48,7 +48,7 @@ func TestHttpDataSource(t *testing.T) {
|
|||
Name: "url_is_empty",
|
||||
Path: testDatasourceEmptyUrl,
|
||||
Error: true,
|
||||
Outputs: map[string]string{
|
||||
ExpectedOutputs: map[string]string{
|
||||
"error": "the `url` must be specified",
|
||||
},
|
||||
},
|
||||
|
|
@ -56,7 +56,7 @@ func TestHttpDataSource(t *testing.T) {
|
|||
Name: "method_is_invalid",
|
||||
Path: testDatasourceInvalidMethod,
|
||||
Error: true,
|
||||
Outputs: map[string]string{
|
||||
ExpectedOutputs: map[string]string{
|
||||
"error": "the `method` must be one of \\[HEAD GET POST PUT DELETE OPTIONS PATCH\\]",
|
||||
},
|
||||
},
|
||||
|
|
@ -88,7 +88,7 @@ func TestHttpDataSource(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if tt.Outputs != nil {
|
||||
if tt.ExpectedOutputs != nil {
|
||||
logs, err := os.Open(logfile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable find %s", logfile)
|
||||
|
|
@ -101,7 +101,7 @@ func TestHttpDataSource(t *testing.T) {
|
|||
}
|
||||
logsString := string(logsBytes)
|
||||
|
||||
for key, val := range tt.Outputs {
|
||||
for key, val := range tt.ExpectedOutputs {
|
||||
if matched, _ := regexp.MatchString(val+".*", logsString); !matched {
|
||||
t.Fatalf(
|
||||
"logs doesn't contain expected log %v with value %v in %q",
|
||||
|
|
|
|||
Loading…
Reference in a new issue