From f60a162a372caf213b7463a33a4837a15f2ae395 Mon Sep 17 00:00:00 2001 From: Sias Mey Date: Tue, 3 Dec 2024 10:20:40 +0200 Subject: [PATCH] fix: add a few more linters (#147) * chore: enable dupword linter * fix: make error switch modern * fix: wrap errors in live tests * fix: add gocritic and listen to it * chore: update lint config * refactor: enable forcetypeassert lint * refactor: re organize json error handling * chore: enable funlen linter * test: use constant for repeated string * test: reformat some long strings for line lenght * chore: enable maintidx linter, excluding generated code * chore: enable nestif linter * test: enable testifylint * chore: enable taglietelle linter * test: enable thelper linter * chore: enable whitespace linter * chore: enable stdlibvars linter * style: format args --- .golangci.yaml | 31 +++--- .../provider/resources/resource_sensor.go | 4 +- internal/provider/util/error_handling.go | 99 ++++++++++++++----- .../resources/agent_group_assignment_test.go | 16 +-- test/live/resources/agent_test.go | 2 +- test/live/resources/group_test.go | 12 +-- .../network_group_assignment_test.go | 66 ++++++------- .../resources/sensor_group_assignment_test.go | 8 +- test/live/resources/sensor_test.go | 8 +- .../service_test_group_assignment_test.go | 8 +- test/live/util/agent.go | 10 +- test/live/util/agent_group_assignment.go | 2 + test/live/util/network_group_assignment.go | 2 + test/live/util/sensor_group_assignment.go | 2 + .../util/service_test_group_assignment.go | 2 + .../agent_group_assignment_test.go | 2 +- test/mocked/datasources/agent_test.go | 2 +- test/mocked/datasources/group_test.go | 2 +- .../network_group_assignment_test.go | 2 +- .../sensor_group_assignment_test.go | 2 +- test/mocked/datasources/sensor_test.go | 2 +- test/mocked/datasources/service_test.go | 2 +- .../service_test_group_assignment_test.go | 2 +- test/mocked/datasources/wired_network_test.go | 2 +- .../datasources/wireless_network_test.go | 2 +- .../resources/agent_group_assignment_test.go | 6 +- test/mocked/resources/agent_test.go | 10 +- test/mocked/resources/group_test.go | 6 +- .../network_group_assignment_test.go | 6 +- .../resources/sensor_group_assignment_test.go | 6 +- test/mocked/resources/sensor_test.go | 8 +- test/mocked/resources/service_test.go | 2 +- .../service_test_group_assignment_test.go | 4 +- test/mocked/resources/wired_network_test.go | 2 +- .../mocked/resources/wireless_network_test.go | 2 +- test/shared/agent.go | 2 + test/shared/sensor.go | 2 + test/shared/service.go | 2 + test/shared/wired_network.go | 2 + test/shared/wireless_network.go | 2 + 40 files changed, 204 insertions(+), 150 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 2b047eac..7e5e9953 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -18,6 +18,10 @@ linters-settings: funlen: lines: 90 statements: 60 + tagliatelle: + case: + rules: + json: snake linters: # See the dedicated "linters" documentation section. @@ -26,32 +30,16 @@ linters: disable: - cyclop # we have gocyclo, apparently its better - execinquery # deprecated - - - contextcheck # we want this - copyloopvar # if we update to later than go 1.22 - - depguard # for banning specific dependencies - - dupl # we want this - - dupword # we want this - - errorlint # we want this - - forcetypeassert # we want this - - funlen # we want this - - goconst # we want this - - gocritic # we want this - intrange # later version of go - # - ireturn # we want this - - lll # we want this - - maintidx # we want this + - mnd # we want this todo: also see gomnd - gomnd # disabled in gl provider todo: also see mnd - noctx # we want this - - nestif # we want this - revive # we want this - - tagliatelle # we want this - - testifylint # we want this - - thelper # we want this - - usestdlibvars # we want this - - whitespace # we want this - - wrapcheck # we want this + - dupl # we want this + - contextcheck # we want this, but the "trivial" fix causes context cancelled errors in tests + - depguard # for banning specific dependencies - canonicalheader # for checking copyright headers - err113 # disabled in gl provider @@ -90,6 +78,9 @@ issues: - linters: - stylecheck + - goconst + - maintidx + - testifylint path: pkg/config-api-client - linters: diff --git a/internal/provider/resources/resource_sensor.go b/internal/provider/resources/resource_sensor.go index 3e6240eb..79a94089 100644 --- a/internal/provider/resources/resource_sensor.go +++ b/internal/provider/resources/resource_sensor.go @@ -105,13 +105,13 @@ func (r *sensorResource) Schema( "notes": schema.StringAttribute{ Description: "The address notes of the sensor.", Optional: true, - // computed because goes from from nil -> "" when sensor becomes configured + // computed because goes from nil -> "" when sensor becomes configured Computed: true, }, "pcap_mode": schema.StringAttribute{ Description: "The packet capture mode of the agent.", Optional: true, - // computed because goes from from nil -> "light" when sensor becomes configured + // computed because goes from nil -> "light" when sensor becomes configured Computed: true, }, }, diff --git a/internal/provider/util/error_handling.go b/internal/provider/util/error_handling.go index b53efcf2..8d57ecd6 100644 --- a/internal/provider/util/error_handling.go +++ b/internal/provider/util/error_handling.go @@ -6,9 +6,11 @@ package util import ( "encoding/json" + "errors" "fmt" "net/http" "net/url" + "strings" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" ) @@ -20,28 +22,17 @@ func GenerateErrorSummary(actionName string, entityName string) string { func RaiseForStatus(response *http.Response, err error) (bool, string) { if err != nil { var detail string - var data map[string]interface{} - - switch e := err.(type) { - case *url.Error: - detail = handleURLError(e) - case *config_api_client.GenericOpenAPIError: - if err := json.NewDecoder(response.Body).Decode(&data); err != nil { - detail = fmt.Sprintf( - "Unexpected error: there was an error decoding the API response body for "+ - "%d status code response.", - response.StatusCode, - ) - } else if message, ok := data["message"]; ok { - detail = message.(string) - if debugID, ok := data["debugId"]; ok { - detail += "\nDebugID: " + debugID.(string) - } - } else { - detail = "Unexpected error: " + e.Error() - } + + var uErr *url.Error + var apiErr *config_api_client.GenericOpenAPIError + + switch { + case errors.As(err, &uErr): + detail = handleURLError(uErr) + case errors.As(err, &apiErr): + detail = handleJSONError(response, apiErr) default: - detail = "Unexpected error: " + e.Error() + detail = "Unexpected error: " + err.Error() } return true, detail @@ -50,12 +41,72 @@ func RaiseForStatus(response *http.Response, err error) (bool, string) { return false, "" } +func handleJSONError( + response *http.Response, + apiErr *config_api_client.GenericOpenAPIError, +) string { + data, err := parseJSONResponse(response) + if err != nil { + return err.Error() + } + + message := buildJSONErrorMsg(data, apiErr) + debugID := buildJSONDebugID(data) + parts := []string{message, debugID} + + return strings.Join(parts, "\n") +} + +func parseJSONResponse(response *http.Response) (map[string]any, error) { + var data map[string]interface{} + + err := json.NewDecoder(response.Body).Decode(&data) + if err != nil { + return map[string]any{}, fmt.Errorf( + "Unexpected error: there was an error decoding the API response body for "+ + "%d status code response.", + response.StatusCode, + ) + } + + return data, nil +} + +func buildJSONErrorMsg(data map[string]any, apiErr *config_api_client.GenericOpenAPIError) string { + message, found := data["message"] + if !found { + return "Unexpected error: " + apiErr.Error() + } + + messageStr, castOK := message.(string) + if !castOK { + return "Unexpected error: " + apiErr.Error() + } + + return messageStr +} + +func buildJSONDebugID(data map[string]any) string { + debugID, found := data["debugId"] + if !found { + return "" + } + + debugIDStr, castOK := debugID.(string) + if !castOK { + return "" + } + + return "DebugID: " + debugIDStr +} + func handleURLError(uErr *url.Error) string { - if uErr.Timeout() { + switch { + case uErr.Timeout(): return "Error: Request timed out. Please check your network." - } else if uErr.Temporary() { + case uErr.Temporary(): return "Error: Temporary network error. Please try again later." - } else { + default: return fmt.Sprintf("URL Error: %v\n", uErr) } } diff --git a/test/live/resources/agent_group_assignment_test.go b/test/live/resources/agent_group_assignment_test.go index e2a2536d..9380c67b 100644 --- a/test/live/resources/agent_group_assignment_test.go +++ b/test/live/resources/agent_group_assignment_test.go @@ -142,18 +142,10 @@ func TestAgentGroupAssignmentResource(t *testing.T) { }, }, CheckDestroy: func(s *terraform.State) error { - assert.Equal(t, util.GetGroupByName(groupName), nil) - assert.Equal(t, util.GetGroupByName(group2Name), nil) - assert.Equal( - t, - util.GetAgentGroupAssignment(resourceIDBeforeRecreate), - nil, - ) - assert.Equal( - t, - util.GetAgentGroupAssignment(resourceIDAfterRecreate), - nil, - ) + assert.Nil(t, util.GetGroupByName(groupName)) + assert.Nil(t, util.GetGroupByName(group2Name)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate)) return nil }, diff --git a/test/live/resources/agent_test.go b/test/live/resources/agent_test.go index 8674423a..905a4ea0 100644 --- a/test/live/resources/agent_test.go +++ b/test/live/resources/agent_test.go @@ -89,7 +89,7 @@ func TestAgentResource(t *testing.T) { }, }, CheckDestroy: func(s *terraform.State) error { - assert.Equal(t, util.GetAgent(agentID), nil) + assert.Nil(t, util.GetAgent(agentID)) return nil }, diff --git a/test/live/resources/group_test.go b/test/live/resources/group_test.go index 1d0f7c53..b3ead7c4 100644 --- a/test/live/resources/group_test.go +++ b/test/live/resources/group_test.go @@ -246,12 +246,12 @@ func TestGroupResource(t *testing.T) { }, }, CheckDestroy: func(s *terraform.State) error { - assert.Equal(t, util.GetGroupByName(groupNameParent), nil) - assert.Equal(t, util.GetGroupByName(groupNameParentUpdated), nil) - assert.Equal(t, util.GetGroupByName(groupNameChild), nil) - assert.Equal(t, util.GetGroupByName(groupNameGrandChild), nil) - assert.Equal(t, util.GetGroupByName(groupNameGrandChildMovedToParent), nil) - assert.Equal(t, util.GetGroupByName(groupNameGrandChildMovedToRoot), nil) + assert.Nil(t, util.GetGroupByName(groupNameParent)) + assert.Nil(t, util.GetGroupByName(groupNameParentUpdated)) + assert.Nil(t, util.GetGroupByName(groupNameChild)) + assert.Nil(t, util.GetGroupByName(groupNameGrandChild)) + assert.Nil(t, util.GetGroupByName(groupNameGrandChildMovedToParent)) + assert.Nil(t, util.GetGroupByName(groupNameGrandChildMovedToRoot)) return nil }, diff --git a/test/live/resources/network_group_assignment_test.go b/test/live/resources/network_group_assignment_test.go index 312e7ae1..a45e7d00 100644 --- a/test/live/resources/network_group_assignment_test.go +++ b/test/live/resources/network_group_assignment_test.go @@ -18,8 +18,9 @@ import ( func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { const ( - groupName = "tf_provider_acceptance_test_network_assignment_resource" - group2Name = "tf_provider_acceptance_test_network_assignment_resource_two" + groupName = "tf_provider_acceptance_test_network_assignment_resource" + group2Name = "tf_provider_acceptance_test_network_assignment_resource_two" + resourceQuery = "hpeuxi_network_group_assignment.my_network_group_assignment" ) var ( @@ -54,12 +55,12 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( // Check configured properties resource.TestCheckResourceAttr( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "network_id", config.WiredNetworkID, ), resource.TestCheckResourceAttrWith( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "group_id", func(group_id string) error { assert.Equal(t, group_id, util.GetGroupByName(groupName).Id) @@ -69,13 +70,12 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { ), // Check properties match what is on backend func(s *terraform.State) error { - resourceName := "hpeuxi_network_group_assignment.my_network_group_assignment" - rs := s.RootModule().Resources[resourceName] + rs := s.RootModule().Resources[resourceQuery] resourceIDBeforeRecreate = rs.Primary.ID return util.CheckStateAgainstNetworkGroupAssignment( t, - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, util.GetNetworkGroupAssignment(resourceIDBeforeRecreate), )(s) }, @@ -83,7 +83,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { }, // ImportState { - ResourceName: "hpeuxi_network_group_assignment.my_network_group_assignment", + ResourceName: resourceQuery, ImportState: true, ImportStateVerify: true, }, @@ -117,12 +117,12 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( // Check configured properties resource.TestCheckResourceAttr( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "network_id", config.WiredNetworkID, ), resource.TestCheckResourceAttrWith( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "group_id", func(group_id string) error { assert.Equal(t, group_id, util.GetGroupByName(group2Name).Id) @@ -132,8 +132,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { ), // Check properties match what is on backend func(s *terraform.State) error { - resourceName := "hpeuxi_network_group_assignment.my_network_group_assignment" - rs := s.RootModule().Resources[resourceName] + rs := s.RootModule().Resources[resourceQuery] resourceIDAfterRecreate = rs.Primary.ID return util.CheckStateAgainstNetworkGroupAssignment( @@ -144,7 +143,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { }, // Check that resource has been recreated resource.TestCheckResourceAttrWith( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "id", func(value string) error { assert.NotEqual(t, value, resourceIDBeforeRecreate) @@ -167,10 +166,10 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { }, }, CheckDestroy: func(s *terraform.State) error { - assert.Equal(t, util.GetGroupByName(groupName), nil) - assert.Equal(t, util.GetGroupByName(group2Name), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate), nil) + assert.Nil(t, util.GetGroupByName(groupName)) + assert.Nil(t, util.GetGroupByName(group2Name)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate)) return nil }, @@ -179,8 +178,9 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { const ( - groupName = "tf_provider_acceptance_test_network_assignment_test" - group2Name = "tf_provider_acceptance_test_network_assignment_test_two" + groupName = "tf_provider_acceptance_test_network_assignment_test" + group2Name = "tf_provider_acceptance_test_network_assignment_test_two" + resourceQuery = "hpeuxi_network_group_assignment.my_network_group_assignment" ) var ( @@ -215,12 +215,12 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( // Check configured properties resource.TestCheckResourceAttr( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "network_id", config.WirelessNetworkID, ), resource.TestCheckResourceAttrWith( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "group_id", func(group_id string) error { assert.Equal(t, group_id, util.GetGroupByName(groupName).Id) @@ -230,13 +230,12 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { ), // Check properties match what is on backend func(s *terraform.State) error { - resourceName := "hpeuxi_network_group_assignment.my_network_group_assignment" - rs := s.RootModule().Resources[resourceName] + rs := s.RootModule().Resources[resourceQuery] resourceIDBeforeRecreate = rs.Primary.ID return util.CheckStateAgainstNetworkGroupAssignment( t, - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, util.GetNetworkGroupAssignment(resourceIDBeforeRecreate), )(s) }, @@ -244,7 +243,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { }, // ImportState { - ResourceName: "hpeuxi_network_group_assignment.my_network_group_assignment", + ResourceName: resourceQuery, ImportState: true, ImportStateVerify: true, }, @@ -278,12 +277,12 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( // Check configured properties resource.TestCheckResourceAttr( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "network_id", config.WirelessNetworkID, ), resource.TestCheckResourceAttrWith( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "group_id", func(group_id string) error { assert.Equal(t, group_id, util.GetGroupByName(group2Name).Id) @@ -293,8 +292,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { ), // Check properties match what is on backend func(s *terraform.State) error { - resourceName := "hpeuxi_network_group_assignment.my_network_group_assignment" - rs := s.RootModule().Resources[resourceName] + rs := s.RootModule().Resources[resourceQuery] resourceIDAfterRecreate = rs.Primary.ID return util.CheckStateAgainstNetworkGroupAssignment( @@ -305,7 +303,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { }, // Check that resource has been recreated resource.TestCheckResourceAttrWith( - "hpeuxi_network_group_assignment.my_network_group_assignment", + resourceQuery, "id", func(value string) error { assert.NotEqual(t, value, resourceIDBeforeRecreate) @@ -328,10 +326,10 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { }, }, CheckDestroy: func(s *terraform.State) error { - assert.Equal(t, util.GetGroupByName(groupName), nil) - assert.Equal(t, util.GetGroupByName(group2Name), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate), nil) + assert.Nil(t, util.GetGroupByName(groupName)) + assert.Nil(t, util.GetGroupByName(group2Name)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate)) return nil }, diff --git a/test/live/resources/sensor_group_assignment_test.go b/test/live/resources/sensor_group_assignment_test.go index 2aa43072..43e5c141 100644 --- a/test/live/resources/sensor_group_assignment_test.go +++ b/test/live/resources/sensor_group_assignment_test.go @@ -158,10 +158,10 @@ func TestSensorGroupAssignmentResource(t *testing.T) { }, }, CheckDestroy: func(s *terraform.State) error { - assert.Equal(t, util.GetGroupByName(groupName), nil) - assert.Equal(t, util.GetGroupByName(group2Name), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate), nil) + assert.Nil(t, util.GetGroupByName(groupName)) + assert.Nil(t, util.GetGroupByName(group2Name)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate)) return nil }, diff --git a/test/live/resources/sensor_test.go b/test/live/resources/sensor_test.go index 4ff52305..1cea892b 100644 --- a/test/live/resources/sensor_test.go +++ b/test/live/resources/sensor_test.go @@ -21,8 +21,12 @@ import ( func TestSensorResource(t *testing.T) { originalSensor := util.GetSensor(config.SensorID) updatedSensor := originalSensor - updatedSensor.Notes = *config_api_client.NewNullableString(config_api_client.PtrString("tf_provider_acceptance_test_update_notes")) - updatedSensor.AddressNote = *config_api_client.NewNullableString(config_api_client.PtrString("tf_provider_acceptance_test_update_address_note")) + updatedSensor.Notes = *config_api_client.NewNullableString( + config_api_client.PtrString("tf_provider_acceptance_test_update_notes"), + ) + updatedSensor.AddressNote = *config_api_client.NewNullableString( + config_api_client.PtrString("tf_provider_acceptance_test_update_address_note"), + ) updatedSensor.PcapMode = *config_api_client.NewNullableString(config_api_client.PtrString("off")) resource.Test(t, resource.TestCase{ diff --git a/test/live/resources/service_test_group_assignment_test.go b/test/live/resources/service_test_group_assignment_test.go index 8da6a7ca..dba9d117 100644 --- a/test/live/resources/service_test_group_assignment_test.go +++ b/test/live/resources/service_test_group_assignment_test.go @@ -161,10 +161,10 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { }, }, CheckDestroy: func(s *terraform.State) error { - assert.Equal(t, util.GetGroupByName(groupName), nil) - assert.Equal(t, util.GetGroupByName(group2Name), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate), nil) - assert.Equal(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate), nil) + assert.Nil(t, util.GetGroupByName(groupName)) + assert.Nil(t, util.GetGroupByName(group2Name)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDBeforeRecreate)) + assert.Nil(t, util.GetAgentGroupAssignment(resourceIDAfterRecreate)) return nil }, diff --git a/test/live/util/agent.go b/test/live/util/agent.go index 9561edb0..8abc5819 100644 --- a/test/live/util/agent.go +++ b/test/live/util/agent.go @@ -65,19 +65,19 @@ func (p ProvisionAgent) Provision() (string, error) { } jsonData, err := json.Marshal(request) if err != nil { - return id, err + return id, fmt.Errorf("ProvisionAgent.Provision marshal json failled: %w", err) } - req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) + req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(jsonData)) if err != nil { - return id, err + return id, fmt.Errorf("ProvisionAgent.Provision build request failled: %w", err) } req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, err := client.Do(req) if err != nil { - return id, err + return id, fmt.Errorf("ProvisionAgent.Provision request Do failled: %w", err) } defer resp.Body.Close() @@ -102,7 +102,7 @@ func (p ProvisionAgent) generateID() (string, error) { // Use the first 16 bytes of the digest to create a UUID v3 uuid, err := uuid.FromBytes(digest[:16]) if err != nil { - return "", err + return "", fmt.Errorf("Failed to create hash from bytes: %w", err) } uuid[6] = (uuid[6] & 0x0f) | 0x30 // Set the version to 3 (MD5-based UUID) uuid[8] = (uuid[8] & 0x3f) | 0x80 // Set the variant to RFC 4122 diff --git a/test/live/util/agent_group_assignment.go b/test/live/util/agent_group_assignment.go index 0d35bd6d..907ed9e5 100644 --- a/test/live/util/agent_group_assignment.go +++ b/test/live/util/agent_group_assignment.go @@ -34,6 +34,8 @@ func CheckStateAgainstAgentGroupAssignment( entity string, agentGroupAssignment config_api_client.AgentGroupAssignmentsItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", agentGroupAssignment.Id), resource.TestCheckResourceAttr(entity, "group_id", agentGroupAssignment.Group.Id), diff --git a/test/live/util/network_group_assignment.go b/test/live/util/network_group_assignment.go index 47c7461f..44857022 100644 --- a/test/live/util/network_group_assignment.go +++ b/test/live/util/network_group_assignment.go @@ -34,6 +34,8 @@ func CheckStateAgainstNetworkGroupAssignment( entity string, networkGroupAssignment config_api_client.NetworkGroupAssignmentsItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", networkGroupAssignment.Id), resource.TestCheckResourceAttr(entity, "group_id", networkGroupAssignment.Group.Id), diff --git a/test/live/util/sensor_group_assignment.go b/test/live/util/sensor_group_assignment.go index 2151eec5..72883cf4 100644 --- a/test/live/util/sensor_group_assignment.go +++ b/test/live/util/sensor_group_assignment.go @@ -34,6 +34,8 @@ func CheckStateAgainstSensorGroupAssignment( entity string, sensorGroupAssignment config_api_client.SensorGroupAssignmentsItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", sensorGroupAssignment.Id), resource.TestCheckResourceAttr(entity, "group_id", sensorGroupAssignment.Group.Id), diff --git a/test/live/util/service_test_group_assignment.go b/test/live/util/service_test_group_assignment.go index b7d1cf8a..5151f332 100644 --- a/test/live/util/service_test_group_assignment.go +++ b/test/live/util/service_test_group_assignment.go @@ -34,6 +34,8 @@ func CheckStateAgainstServiceTestGroupAssignment( entity string, serviceTestGroupAssignment config_api_client.ServiceTestGroupAssignmentsItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", serviceTestGroupAssignment.Id), resource.TestCheckResourceAttr(entity, "group_id", serviceTestGroupAssignment.Group.Id), diff --git a/test/mocked/datasources/agent_group_assignment_test.go b/test/mocked/datasources/agent_group_assignment_test.go index cd26e5ae..37c4019f 100644 --- a/test/mocked/datasources/agent_group_assignment_test.go +++ b/test/mocked/datasources/agent_group_assignment_test.go @@ -101,7 +101,7 @@ func TestAgentGroupAssignmentDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/agent_test.go b/test/mocked/datasources/agent_test.go index 3935b0a8..396b803d 100644 --- a/test/mocked/datasources/agent_test.go +++ b/test/mocked/datasources/agent_test.go @@ -75,7 +75,7 @@ func TestAgentDataSourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( shared.CheckStateAgainstAgent(t, "data.hpeuxi_agent.my_agent", agent), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/group_test.go b/test/mocked/datasources/group_test.go index ac3c9775..ac703b1f 100644 --- a/test/mocked/datasources/group_test.go +++ b/test/mocked/datasources/group_test.go @@ -87,7 +87,7 @@ func TestGroupDataSourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.hpeuxi_group.my_group", "id", "id"), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/network_group_assignment_test.go b/test/mocked/datasources/network_group_assignment_test.go index 27ba5f5a..aa15d4d6 100644 --- a/test/mocked/datasources/network_group_assignment_test.go +++ b/test/mocked/datasources/network_group_assignment_test.go @@ -101,7 +101,7 @@ func TestNetworkGroupAssignmentDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/sensor_group_assignment_test.go b/test/mocked/datasources/sensor_group_assignment_test.go index 003f22c1..372b2f72 100644 --- a/test/mocked/datasources/sensor_group_assignment_test.go +++ b/test/mocked/datasources/sensor_group_assignment_test.go @@ -101,7 +101,7 @@ func TestSensorGroupAssignmentDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/sensor_test.go b/test/mocked/datasources/sensor_test.go index 07f6d1e6..a30bf252 100644 --- a/test/mocked/datasources/sensor_test.go +++ b/test/mocked/datasources/sensor_test.go @@ -75,7 +75,7 @@ func TestSensorDataSourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( shared.CheckStateAgainstSensor(t, "data.hpeuxi_sensor.my_sensor", sensor), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/service_test.go b/test/mocked/datasources/service_test.go index 14584f3a..f1ba49ae 100644 --- a/test/mocked/datasources/service_test.go +++ b/test/mocked/datasources/service_test.go @@ -83,7 +83,7 @@ func TestServiceTestDataSourceTooManyRequestsHandling(t *testing.T) { serviceTest, ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/service_test_group_assignment_test.go b/test/mocked/datasources/service_test_group_assignment_test.go index 35532e3f..7fc5a24f 100644 --- a/test/mocked/datasources/service_test_group_assignment_test.go +++ b/test/mocked/datasources/service_test_group_assignment_test.go @@ -101,7 +101,7 @@ func TestServiceTestGroupAssignmentDataSourceTooManyRequestsHandling(t *testing. "id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/wired_network_test.go b/test/mocked/datasources/wired_network_test.go index 8769b7c3..56cdab81 100644 --- a/test/mocked/datasources/wired_network_test.go +++ b/test/mocked/datasources/wired_network_test.go @@ -83,7 +83,7 @@ func TestWiredNetworkDataSourceTooManyRequestsHandling(t *testing.T) { wiredNetwork, ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/datasources/wireless_network_test.go b/test/mocked/datasources/wireless_network_test.go index a377371c..cb633531 100644 --- a/test/mocked/datasources/wireless_network_test.go +++ b/test/mocked/datasources/wireless_network_test.go @@ -91,7 +91,7 @@ func TestWirelessNetworkDataSourceTooManyRequestsHandling(t *testing.T) { wirelessNetwork, ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/agent_group_assignment_test.go b/test/mocked/resources/agent_group_assignment_test.go index 75e4da14..daaffaee 100644 --- a/test/mocked/resources/agent_group_assignment_test.go +++ b/test/mocked/resources/agent_group_assignment_test.go @@ -359,7 +359,7 @@ func TestAgentGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { "agent_group_assignment_id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -382,7 +382,7 @@ func TestAgentGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { ImportState: true, ImportStateVerify: true, Check: func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -411,7 +411,7 @@ func TestAgentGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { }, Config: provider.ProviderConfig, Check: func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/agent_test.go b/test/mocked/resources/agent_test.go index 3f8f8538..0850225e 100644 --- a/test/mocked/resources/agent_test.go +++ b/test/mocked/resources/agent_test.go @@ -144,7 +144,7 @@ func TestAgentResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( shared.CheckStateAgainstAgent(t, "hpeuxi_agent.my_agent", agent), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -177,7 +177,7 @@ func TestAgentResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( shared.CheckStateAgainstAgent(t, "hpeuxi_agent.my_agent", updatedAgent), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -196,7 +196,7 @@ func TestAgentResourceTooManyRequestsHandling(t *testing.T) { Config: provider.ProviderConfig, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -300,7 +300,7 @@ func TestAgentResourceHttpErrorHandling(t *testing.T) { "httpStatusCode": http.StatusUnprocessableEntity, "errorCode": "HPE_GL_UXI_INVALID_PCAP_MODE_ERROR", "message": "Unable to update agent - pcap_mode must be one the following ['light', 'full', 'off'].", - "debugId": "12312-123123-123123-1231212", + "debugId": "debugId", "type": "hpe.greenlake.uxi.invalid_pcap_mode", }) }, @@ -311,7 +311,7 @@ func TestAgentResourceHttpErrorHandling(t *testing.T) { pcap_mode = "light" }`, ExpectError: regexp.MustCompile( - `(?s)Unable to update agent - pcap_mode must be one the following \['light',\s*'full', 'off'\].\s*DebugID: 12312-123123-123123-1231212`, + `(?s)Unable to update agent - pcap_mode must be one the following \['light',\s*'full', 'off'\].\s*DebugID: debugId`, ), }, // Delete HTTP error diff --git a/test/mocked/resources/group_test.go b/test/mocked/resources/group_test.go index a811d477..27f8389e 100644 --- a/test/mocked/resources/group_test.go +++ b/test/mocked/resources/group_test.go @@ -265,7 +265,7 @@ func TestGroupResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("hpeuxi_group.my_group", "id", "id"), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -292,7 +292,7 @@ func TestGroupResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("hpeuxi_group.my_group", "id", "id"), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -330,7 +330,7 @@ func TestGroupResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("hpeuxi_group.my_group", "name", "name_2"), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/network_group_assignment_test.go b/test/mocked/resources/network_group_assignment_test.go index 22ec379c..3763ccac 100644 --- a/test/mocked/resources/network_group_assignment_test.go +++ b/test/mocked/resources/network_group_assignment_test.go @@ -674,7 +674,7 @@ func TestNetworkGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { "network_id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -701,7 +701,7 @@ func TestNetworkGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { ImportStateVerify: true, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -746,7 +746,7 @@ func TestNetworkGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/sensor_group_assignment_test.go b/test/mocked/resources/sensor_group_assignment_test.go index 89343b97..aceb14ba 100644 --- a/test/mocked/resources/sensor_group_assignment_test.go +++ b/test/mocked/resources/sensor_group_assignment_test.go @@ -371,7 +371,7 @@ func TestSensorGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { "sensor_group_assignment_id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -398,7 +398,7 @@ func TestSensorGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { ImportStateVerify: true, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -446,7 +446,7 @@ func TestSensorGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/sensor_test.go b/test/mocked/resources/sensor_test.go index 85b80bd9..74abd1e4 100644 --- a/test/mocked/resources/sensor_test.go +++ b/test/mocked/resources/sensor_test.go @@ -165,7 +165,7 @@ func TestSensorResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( shared.CheckStateAgainstSensor(t, "hpeuxi_sensor.my_sensor", sensor), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -199,7 +199,7 @@ func TestSensorResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( shared.CheckStateAgainstSensor(t, "hpeuxi_sensor.my_sensor", updatedSensor), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -317,7 +317,7 @@ func TestSensorResourceHttpErrorHandling(t *testing.T) { "httpStatusCode": http.StatusUnprocessableEntity, "errorCode": "HPE_GL_UXI_INVALID_PCAP_MODE_ERROR", "message": "Unable to update sensor - pcap_mode must be one the following ['light', 'full', 'off'].", - "debugId": "12312-123123-123123-1231212", + "debugId": "debugId", "type": "hpe.greenlake.uxi.invalid_pcap_mode", }) }, @@ -329,7 +329,7 @@ func TestSensorResourceHttpErrorHandling(t *testing.T) { pcap_mode = "light" }`, ExpectError: regexp.MustCompile( - `(?s)Unable to update sensor - pcap_mode must be one the following \['light',\s*'full', 'off'\].\s*DebugID: 12312-123123-123123-1231212`, + `(?s)Unable to update sensor - pcap_mode must be one the following \['light',\s*'full', 'off'\].\s*DebugID: debugId`, ), }, // Remove sensor from state diff --git a/test/mocked/resources/service_test.go b/test/mocked/resources/service_test.go index ccb9f1f2..048a7fb6 100644 --- a/test/mocked/resources/service_test.go +++ b/test/mocked/resources/service_test.go @@ -152,7 +152,7 @@ func TestServiceTestResourceTooManyRequestsHandling(t *testing.T) { serviceTest, ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/service_test_group_assignment_test.go b/test/mocked/resources/service_test_group_assignment_test.go index f1bf3a9f..53a51cb9 100644 --- a/test/mocked/resources/service_test_group_assignment_test.go +++ b/test/mocked/resources/service_test_group_assignment_test.go @@ -359,7 +359,7 @@ func TestServiceTestGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) "service_test_group_assignment_id", ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, @@ -385,7 +385,7 @@ func TestServiceTestGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) ImportStateVerify: true, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/wired_network_test.go b/test/mocked/resources/wired_network_test.go index 2d793c59..02815359 100644 --- a/test/mocked/resources/wired_network_test.go +++ b/test/mocked/resources/wired_network_test.go @@ -152,7 +152,7 @@ func TestWiredNetworkResourceTooManyRequestsHandling(t *testing.T) { wiredNetwork, ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/mocked/resources/wireless_network_test.go b/test/mocked/resources/wireless_network_test.go index 7718ab97..230ccc27 100644 --- a/test/mocked/resources/wireless_network_test.go +++ b/test/mocked/resources/wireless_network_test.go @@ -179,7 +179,7 @@ func TestWirelessNetworkResourceTooManyRequestsHandling(t *testing.T) { wirelessNetwork, ), func(s *terraform.State) error { - assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, 0, mockTooManyRequests.Mock.Request().Counter) return nil }, diff --git a/test/shared/agent.go b/test/shared/agent.go index dcb68167..d3e2dac9 100644 --- a/test/shared/agent.go +++ b/test/shared/agent.go @@ -18,6 +18,8 @@ func CheckStateAgainstAgent( stateEntity string, agent config_api_client.AgentItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(stateEntity, "id", agent.Id), resource.TestCheckResourceAttr(stateEntity, "serial", agent.Serial), diff --git a/test/shared/sensor.go b/test/shared/sensor.go index 9205d8b7..d048553b 100644 --- a/test/shared/sensor.go +++ b/test/shared/sensor.go @@ -18,6 +18,8 @@ func CheckStateAgainstSensor( entity string, sensor config_api_client.SensorItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", sensor.Id), resource.TestCheckResourceAttr(entity, "serial", sensor.Serial), diff --git a/test/shared/service.go b/test/shared/service.go index b73f01e5..94460010 100644 --- a/test/shared/service.go +++ b/test/shared/service.go @@ -18,6 +18,8 @@ func CheckStateAgainstServiceTest( entity string, serviceTest config_api_client.ServiceTestsListItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", serviceTest.Id), resource.TestCheckResourceAttr(entity, "category", serviceTest.Category), diff --git a/test/shared/wired_network.go b/test/shared/wired_network.go index 3422c98b..5d9508b0 100644 --- a/test/shared/wired_network.go +++ b/test/shared/wired_network.go @@ -19,6 +19,8 @@ func CheckStateAgainstWiredNetwork( entity string, wiredNetwork config_api_client.WiredNetworksItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", wiredNetwork.Id), resource.TestCheckResourceAttrWith( diff --git a/test/shared/wireless_network.go b/test/shared/wireless_network.go index b58c36a0..7d778d51 100644 --- a/test/shared/wireless_network.go +++ b/test/shared/wireless_network.go @@ -19,6 +19,8 @@ func CheckStateAgainstWirelessNetwork( entity string, wirelessNetwork config_api_client.WirelessNetworksItem, ) resource.TestCheckFunc { + t.Helper() + return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(entity, "id", wirelessNetwork.Id), resource.TestCheckResourceAttr(entity, "ssid", wirelessNetwork.Ssid),