From 35d14902b0fb097b29568b9b79bbf12c5684281e Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Mon, 4 Nov 2024 14:48:49 -0500 Subject: [PATCH] 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. --- datasource/http/data_acc_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/datasource/http/data_acc_test.go b/datasource/http/data_acc_test.go index 25754488b..788c72706 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,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",