diff --git a/datasource/http/data_acc_test.go b/datasource/http/data_acc_test.go index 57d45bc7922..788c727065c 100644 --- a/datasource/http/data_acc_test.go +++ b/datasource/http/data_acc_test.go @@ -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,8 +56,8 @@ func TestHttpDataSource(t *testing.T) { Name: "method_is_invalid", Path: testDatasourceInvalidMethod, Error: true, - Outputs: map[string]string{ - "error": "the `method` must be one of [HEAD GET POST PUT DELETE OPTIONS PATCH]", + 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",