From 795aef8614a2526d7429748568819af6c032346b Mon Sep 17 00:00:00 2001 From: Alistair Yan <52126234+1riatsila1@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:21:34 +0400 Subject: [PATCH] fix: improve live acceptance tests (#101) --- Justfile | 8 +- go.mod | 7 +- internal/provider/resources/agent.go | 5 + .../resources/agent_group_assignment.go | 6 + .../resources/network_group_assignment.go | 6 + .../resources/sensor_group_assignment.go | 5 + .../resources/service_group_assignment.go | 6 + test/live/config/config.go | 2 +- .../agent_group_assignment_test.go | 2 +- test/live/datasources/group_test.go | 6 +- .../resources/agent_group_assignment_test.go | 48 +++++-- test/live/resources/agent_test.go | 17 ++- test/live/resources/group_test.go | 92 +++++++++++-- .../network_group_assignment_test.go | 125 +++++++++++++++--- .../resources/sensor_group_assignment_test.go | 57 ++++++-- .../service_test_group_assignment_test.go | 64 +++++++-- test/live/util/agent.go | 24 +++- test/live/util/agent_group_assignment.go | 10 +- test/live/util/network_group_assignment.go | 4 +- test/live/util/sensor.go | 11 +- test/live/util/sensor_group_assignment.go | 4 +- test/live/util/service.go | 4 +- .../util/service_test_group_assignment.go | 4 +- test/live/util/util.go | 21 +-- test/live/util/wired_network.go | 7 +- test/live/util/wireless_network.go | 7 +- .../agent_group_assignment_test.go | 4 +- test/mocked/datasources/agent_test.go | 4 +- test/mocked/datasources/group_test.go | 4 +- .../network_group_assignment_test.go | 4 +- .../sensor_group_assignment_test.go | 4 +- test/mocked/datasources/sensor_test.go | 4 +- test/mocked/datasources/service_test.go | 4 +- .../service_test_group_assignment_test.go | 4 +- test/mocked/datasources/wired_network_test.go | 5 +- .../datasources/wireless_network_test.go | 5 +- .../resources/agent_group_assignment_test.go | 8 +- test/mocked/resources/agent_test.go | 8 +- 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 | 6 +- .../service_test_group_assignment_test.go | 4 +- 43 files changed, 488 insertions(+), 150 deletions(-) diff --git a/Justfile b/Justfile index 72b57eb6..5abd26d1 100644 --- a/Justfile +++ b/Justfile @@ -101,7 +101,13 @@ acceptance-tests +ARGS='': echo if [[ $REPLY =~ ^[Yy]$ ]] then - TF_ACC=1 go test -v ./test/live/... -race -covermode=atomic -coverprofile=.coverage {{ ARGS }} + # we run these seperately so that they do not interfere with each other since GoLang executes + # tests in different directories at the same time + for dir in "datasources" "resources" + do + echo "Running tests in $dir..." + TF_ACC=1 go test -v ./test/live/$dir/... -race {{ ARGS }} + done fi diff --git a/go.mod b/go.mod index 55cfe9ef..a604904d 100644 --- a/go.mod +++ b/go.mod @@ -6,11 +6,12 @@ toolchain go1.22.5 require ( github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client v0.0.0-00010101000000-000000000000 + github.com/google/uuid v1.6.0 github.com/h2non/gock v1.2.0 github.com/hashicorp/terraform-plugin-framework v1.10.0 github.com/hashicorp/terraform-plugin-go v0.23.0 github.com/hashicorp/terraform-plugin-testing v1.10.0 - github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 + github.com/stretchr/testify v1.9.0 golang.org/x/oauth2 v0.17.0 ) @@ -19,10 +20,10 @@ require ( github.com/agext/levenshtein v1.2.2 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect @@ -52,6 +53,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect @@ -67,6 +69,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/grpc v1.63.2 // indirect google.golang.org/protobuf v1.34.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client => ./pkg/config-api-client diff --git a/internal/provider/resources/agent.go b/internal/provider/resources/agent.go index 0a345c16..06ffa2ff 100644 --- a/internal/provider/resources/agent.go +++ b/internal/provider/resources/agent.go @@ -2,6 +2,7 @@ package resources import ( "context" + "net/http" "github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util" "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" @@ -223,6 +224,10 @@ func (r *agentResource) Delete( errorPresent, errorDetail := util.RaiseForStatus(response, err) if errorPresent { + if response.StatusCode == http.StatusNotFound { + resp.State.RemoveResource(ctx) + return + } resp.Diagnostics.AddError(util.GenerateErrorSummary("delete", "uxi_agent"), errorDetail) return } diff --git a/internal/provider/resources/agent_group_assignment.go b/internal/provider/resources/agent_group_assignment.go index c2f125af..798f1d66 100644 --- a/internal/provider/resources/agent_group_assignment.go +++ b/internal/provider/resources/agent_group_assignment.go @@ -2,6 +2,8 @@ package resources import ( "context" + "net/http" + "github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util" "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" @@ -206,6 +208,10 @@ func (r *agentGroupAssignmentResource) Delete( errorPresent, errorDetail := util.RaiseForStatus(response, err) if errorPresent { + if response.StatusCode == http.StatusNotFound { + resp.State.RemoveResource(ctx) + return + } resp.Diagnostics.AddError( util.GenerateErrorSummary("delete", "uxi_agent_group_assignment"), errorDetail, diff --git a/internal/provider/resources/network_group_assignment.go b/internal/provider/resources/network_group_assignment.go index 096a544c..d9c8efb2 100644 --- a/internal/provider/resources/network_group_assignment.go +++ b/internal/provider/resources/network_group_assignment.go @@ -2,6 +2,8 @@ package resources import ( "context" + "net/http" + "github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util" "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" @@ -218,6 +220,10 @@ func (r *networkGroupAssignmentResource) Delete( errorPresent, errorDetail := util.RaiseForStatus(response, err) if errorPresent { + if response.StatusCode == http.StatusNotFound { + resp.State.RemoveResource(ctx) + return + } resp.Diagnostics.AddError( util.GenerateErrorSummary("delete", "uxi_network_group_assignment"), errorDetail, diff --git a/internal/provider/resources/sensor_group_assignment.go b/internal/provider/resources/sensor_group_assignment.go index 6b9db512..6e5ba593 100644 --- a/internal/provider/resources/sensor_group_assignment.go +++ b/internal/provider/resources/sensor_group_assignment.go @@ -2,6 +2,7 @@ package resources import ( "context" + "net/http" "github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" @@ -218,6 +219,10 @@ func (r *sensorGroupAssignmentResource) Delete( errorPresent, errorDetail := util.RaiseForStatus(response, err) if errorPresent { + if response.StatusCode == http.StatusNotFound { + resp.State.RemoveResource(ctx) + return + } resp.Diagnostics.AddError( util.GenerateErrorSummary("delete", "uxi_sensor_group_assignment"), errorDetail, diff --git a/internal/provider/resources/service_group_assignment.go b/internal/provider/resources/service_group_assignment.go index 40c9354e..9c3a814e 100644 --- a/internal/provider/resources/service_group_assignment.go +++ b/internal/provider/resources/service_group_assignment.go @@ -2,6 +2,8 @@ package resources import ( "context" + "net/http" + "github.com/aruba-uxi/terraform-provider-hpeuxi/internal/provider/util" "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" @@ -221,6 +223,10 @@ func (r *serviceTestGroupAssignmentResource) Delete( errorPresent, errorDetail := util.RaiseForStatus(response, err) if errorPresent { + if response.StatusCode == http.StatusNotFound { + resp.State.RemoveResource(ctx) + return + } resp.Diagnostics.AddError( util.GenerateErrorSummary("delete", "uxi_service_test_group_assignment"), errorDetail, diff --git a/test/live/config/config.go b/test/live/config/config.go index 0abcdc0b..7e3b671b 100644 --- a/test/live/config/config.go +++ b/test/live/config/config.go @@ -4,7 +4,7 @@ package config // Configuration-API Acceptance Testing (844457745a1111ef880836000a52e73e) // And therefore the client_id and client_secret used for the acceptance tests must match this // customer. -const AgentPermanentId = "8260f349-5c73-394a-b786-57985d001763" +const AgentPermanentId = "55277822-c65a-35f7-8b21-d4a9893ec0bb" const AgentCreateSerial = "56fb38331f19d278" const CustomerId = "9c16d493-7649-40bc-975b-07422d227c0b" const GroupIdRoot = "07422d227c0b" diff --git a/test/live/datasources/agent_group_assignment_test.go b/test/live/datasources/agent_group_assignment_test.go index 693682b4..fd6a8e83 100644 --- a/test/live/datasources/agent_group_assignment_test.go +++ b/test/live/datasources/agent_group_assignment_test.go @@ -48,7 +48,7 @@ func TestAgentGroupAssignmentDataSource(t *testing.T) { return util.CheckStateAgainstAgentGroupAssignment( t, "data.uxi_agent_group_assignment.my_agent_group_assignment", - util.GetAgentGroupAssignment(rs.Primary.ID), + *util.GetAgentGroupAssignment(rs.Primary.ID), )(s) }, ), diff --git a/test/live/datasources/group_test.go b/test/live/datasources/group_test.go index 7906a25c..d734290b 100644 --- a/test/live/datasources/group_test.go +++ b/test/live/datasources/group_test.go @@ -8,7 +8,7 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/util" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestGroupDataSource(t *testing.T) { @@ -45,7 +45,7 @@ func TestGroupDataSource(t *testing.T) { "data.uxi_group.my_group", "id", func(value string) error { - st.Assert(t, value, util.GetGroupByName(groupName).Id) + assert.Equal(t, value, util.GetGroupByName(groupName).Id) return nil }, ), @@ -54,7 +54,7 @@ func TestGroupDataSource(t *testing.T) { "data.uxi_group.my_group", "path", func(value string) error { - st.Assert(t, value, util.GetGroupByName(groupName).Path) + assert.Equal(t, value, util.GetGroupByName(groupName).Path) return nil }, ), diff --git a/test/live/resources/agent_group_assignment_test.go b/test/live/resources/agent_group_assignment_test.go index 4b672f6f..3467d5b1 100644 --- a/test/live/resources/agent_group_assignment_test.go +++ b/test/live/resources/agent_group_assignment_test.go @@ -8,17 +8,23 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/util" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestAgentGroupAssignmentResource(t *testing.T) { - const groupName = "tf_provider_acceptance_test_agent_group_assignment_resource" - const group2Name = "tf_provider_acceptance_test_agent_group_assignment_resource_two" + const ( + groupName = "tf_provider_acceptance_test_agent_group_assignment_resource" + group2Name = "tf_provider_acceptance_test_agent_group_assignment_resource_two" + ) + var ( + resourceIdBeforeRecreate string + resourceIdAfterRecreate string + ) resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Creating a agent group assignment + // Creating { Config: provider.ProviderConfig + ` resource "uxi_group" "my_group" { @@ -46,7 +52,7 @@ func TestAgentGroupAssignmentResource(t *testing.T) { "uxi_agent_group_assignment.my_agent_group_assignment", "group_id", func(value string) error { - st.Assert(t, util.GetGroupByName(groupName).Id, value) + assert.Equal(t, util.GetGroupByName(groupName).Id, value) return nil }, ), @@ -54,21 +60,22 @@ func TestAgentGroupAssignmentResource(t *testing.T) { func(s *terraform.State) error { resourceName := "uxi_agent_group_assignment.my_agent_group_assignment" rs := s.RootModule().Resources[resourceName] + resourceIdBeforeRecreate = rs.Primary.ID return util.CheckStateAgainstAgentGroupAssignment( t, "uxi_agent_group_assignment.my_agent_group_assignment", - util.GetAgentGroupAssignment(rs.Primary.ID), + *util.GetAgentGroupAssignment(resourceIdBeforeRecreate), )(s) }, ), }, - // ImportState testing + // ImportState { ResourceName: "uxi_agent_group_assignment.my_agent_group_assignment", ImportState: true, ImportStateVerify: true, }, - // Update testing + // Update { Config: provider.ProviderConfig + ` // the original resources @@ -103,7 +110,7 @@ func TestAgentGroupAssignmentResource(t *testing.T) { "uxi_agent_group_assignment.my_agent_group_assignment", "group_id", func(value string) error { - st.Assert(t, util.GetGroupByName(group2Name).Id, value) + assert.Equal(t, util.GetGroupByName(group2Name).Id, value) return nil }, ), @@ -111,15 +118,34 @@ func TestAgentGroupAssignmentResource(t *testing.T) { func(s *terraform.State) error { resourceName := "uxi_agent_group_assignment.my_agent_group_assignment" rs := s.RootModule().Resources[resourceName] + resourceIdAfterRecreate = rs.Primary.ID return util.CheckStateAgainstAgentGroupAssignment( t, "uxi_agent_group_assignment.my_agent_group_assignment", - util.GetAgentGroupAssignment(rs.Primary.ID), + *util.GetAgentGroupAssignment(resourceIdAfterRecreate), )(s) }, ), }, - // Delete testing happens automatically + // Delete + { + Config: provider.ProviderConfig, + }, + }, + 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, + ) + return nil }, }) } diff --git a/test/live/resources/agent_test.go b/test/live/resources/agent_test.go index deb802ec..23b3a2ff 100644 --- a/test/live/resources/agent_test.go +++ b/test/live/resources/agent_test.go @@ -9,6 +9,8 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/util" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" ) func TestAgentResource(t *testing.T) { @@ -57,19 +59,19 @@ func TestAgentResource(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("uxi_agent.my_agent", "id", agentId), resource.TestCheckResourceAttr("uxi_agent.my_agent", "name", agentName), resource.TestCheckResourceAttr("uxi_agent.my_agent", "notes", ""), resource.TestCheckResourceAttr("uxi_agent.my_agent", "pcap_mode", "light"), - resource.TestCheckResourceAttr("uxi_agent.my_agent", "id", agentId), ), }, - // ImportState testing + // ImportState { ResourceName: "uxi_agent.my_agent", ImportState: true, ImportStateVerify: true, }, - // Update testing + // Update { Config: provider.ProviderConfig + ` resource "uxi_agent" "my_agent" { @@ -84,7 +86,14 @@ func TestAgentResource(t *testing.T) { resource.TestCheckResourceAttr("uxi_agent.my_agent", "pcap_mode", "off"), ), }, - // Delete testing happen automatically + // Delete + { + Config: provider.ProviderConfig, + }, + }, + CheckDestroy: func(s *terraform.State) error { + assert.Equal(t, util.GetAgent(agentId), nil) + return nil }, }) } diff --git a/test/live/resources/group_test.go b/test/live/resources/group_test.go index 745f1dee..fbab59c1 100644 --- a/test/live/resources/group_test.go +++ b/test/live/resources/group_test.go @@ -9,6 +9,8 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/util" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" ) type Fetcher interface { @@ -16,17 +18,21 @@ type Fetcher interface { } func TestGroupResource(t *testing.T) { - const groupNameParent = "tf_provider_acceptance_test_parent" - const groupNameParentUpdated = groupNameParent + "_updated" - const groupNameChild = "tf_provider_acceptance_test_child" - const groupNameGrandChild = "tf_provider_acceptance_test_grandchild" - const groupNameGrandChildMovedToParent = groupNameGrandChild + "_moved_to_parent" - const groupNameGrandChildMovedToRoot = groupNameGrandChild + "_moved_to_root" + const ( + groupNameParent = "tf_provider_acceptance_test_group_resource_parent" + groupNameParentUpdated = groupNameParent + "_updated" + groupNameChild = "tf_provider_acceptance_test_group_resource__child" + groupNameGrandChild = "tf_provider_acceptance_test_group_resource__grandchild" + groupNameGrandChildMovedToParent = groupNameGrandChild + "_moved_to_parent" + groupNameGrandChildMovedToRoot = groupNameGrandChild + "_moved_to_root" + ) + + var resourceIdBeforeRecreate string resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Create and Read testing + // Create { // Node without parent (attached to root) Config: provider.ProviderConfig + ` @@ -34,13 +40,21 @@ func TestGroupResource(t *testing.T) { name = "` + groupNameParent + `" }`, Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrWith( + "uxi_group.parent", + "id", + func(value string) error { + assert.Equal(t, value, util.GetGroupByName(groupNameParent).Id) + return nil + }, + ), resource.TestCheckResourceAttr( "uxi_group.parent", "name", groupNameParent, ), resource.TestCheckNoResourceAttr("uxi_group.parent", "parent_group_id"), ), }, - // ImportState testing + // ImportState { ResourceName: "uxi_group.parent", ImportState: true, @@ -53,6 +67,14 @@ func TestGroupResource(t *testing.T) { name = "` + groupNameParentUpdated + `" }`, Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrWith( + "uxi_group.parent", + "id", + func(value string) error { + assert.Equal(t, value, util.GetGroupByName(groupNameParentUpdated).Id) + return nil + }, + ), resource.TestCheckResourceAttr( "uxi_group.parent", "name", @@ -81,6 +103,14 @@ func TestGroupResource(t *testing.T) { parent_group_id = uxi_group.child.id }`, Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrWith( + "uxi_group.child", + "id", + func(value string) error { + assert.Equal(t, value, util.GetGroupByName(groupNameChild).Id) + return nil + }, + ), resource.TestCheckResourceAttr( "uxi_group.child", "name", @@ -93,6 +123,17 @@ func TestGroupResource(t *testing.T) { return checkGroupIsChildOfNode(parentGroupId, groupNameParentUpdated) }, ), + resource.TestCheckResourceAttrWith( + "uxi_group.grandchild", + "id", + func(value string) error { + resourceIdBeforeRecreate = util.GetGroupByName( + groupNameGrandChild, + ).Id + assert.Equal(t, value, resourceIdBeforeRecreate) + return nil + }, + ), resource.TestCheckResourceAttr( "uxi_group.grandchild", "name", @@ -125,6 +166,18 @@ func TestGroupResource(t *testing.T) { parent_group_id = uxi_group.parent.id }`, Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrWith( + "uxi_group.grandchild", + "id", + func(value string) error { + assert.Equal( + t, + value, + util.GetGroupByName(groupNameGrandChildMovedToParent).Id, + ) + return nil + }, + ), resource.TestCheckResourceAttr( "uxi_group.grandchild", "name", @@ -137,6 +190,15 @@ func TestGroupResource(t *testing.T) { return checkGroupIsChildOfNode(parentGroupId, groupNameParentUpdated) }, ), + // Check that resource has been recreated + resource.TestCheckResourceAttrWith( + "uxi_group.grandchild", + "id", + func(value string) error { + assert.NotEqual(t, value, resourceIdBeforeRecreate) + return nil + }, + ), ), }, // Update non root node group back to the root node by removing parent_group_id @@ -167,7 +229,19 @@ func TestGroupResource(t *testing.T) { ), ), }, - // Deletes happen automatically + // Delete + { + Config: provider.ProviderConfig, + }, + }, + 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) + return nil }, }) } diff --git a/test/live/resources/network_group_assignment_test.go b/test/live/resources/network_group_assignment_test.go index 2121d02d..9473668e 100644 --- a/test/live/resources/network_group_assignment_test.go +++ b/test/live/resources/network_group_assignment_test.go @@ -7,18 +7,26 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/util" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" ) func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { - const groupName = "tf_provider_acceptance_test_network_assignment_test" - const group2Name = "tf_provider_acceptance_test_network_assignment_test_two" + const ( + groupName = "tf_provider_acceptance_test_network_assignment_resource" + group2Name = "tf_provider_acceptance_test_network_assignment_resource_two" + ) + + var ( + resourceIdBeforeRecreate string + resourceIdAfterRecreate string + ) // Test Wired Network Group Assignment resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Creating a network group assignment + // Creating { Config: provider.ProviderConfig + ` resource "uxi_group" "my_group" { @@ -39,6 +47,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { group_id = uxi_group.my_group.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_network_group_assignment.my_network_group_assignment", "network_id", @@ -48,19 +57,30 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { "uxi_network_group_assignment.my_network_group_assignment", "group_id", func(group_id string) error { - st.Assert(t, group_id, util.GetGroupByName(groupName).Id) + assert.Equal(t, group_id, util.GetGroupByName(groupName).Id) return nil }, ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_network_group_assignment.my_network_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdBeforeRecreate = rs.Primary.ID + return util.CheckStateAgainstNetworkGroupAssignment( + t, + "uxi_network_group_assignment.my_network_group_assignment", + util.GetNetworkGroupAssignment(resourceIdBeforeRecreate), + )(s) + }, ), }, - // ImportState testing + // ImportState { ResourceName: "uxi_network_group_assignment.my_network_group_assignment", ImportState: true, ImportStateVerify: true, }, - // Update and Read testing + // Update { Config: provider.ProviderConfig + ` // the original resources @@ -88,6 +108,7 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { group_id = uxi_group.my_group_2.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_network_group_assignment.my_network_group_assignment", "network_id", @@ -97,7 +118,27 @@ func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { "uxi_network_group_assignment.my_network_group_assignment", "group_id", func(group_id string) error { - st.Assert(t, group_id, util.GetGroupByName(group2Name).Id) + assert.Equal(t, group_id, util.GetGroupByName(group2Name).Id) + return nil + }, + ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_network_group_assignment.my_network_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdAfterRecreate = rs.Primary.ID + return util.CheckStateAgainstNetworkGroupAssignment( + t, + "uxi_network_group_assignment.my_network_group_assignment", + util.GetNetworkGroupAssignment(resourceIdAfterRecreate), + )(s) + }, + // Check that resource has been recreated + resource.TestCheckResourceAttrWith( + "uxi_network_group_assignment.my_network_group_assignment", + "id", + func(value string) error { + assert.NotEqual(t, value, resourceIdBeforeRecreate) return nil }, ), @@ -115,18 +156,32 @@ 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) + return nil + }, }) } func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { - const groupName = "tf_provider_acceptance_test_network_assignment_test" - const group2Name = "tf_provider_acceptance_test_network_assignment_test_two" + const ( + groupName = "tf_provider_acceptance_test_network_assignment_test" + group2Name = "tf_provider_acceptance_test_network_assignment_test_two" + ) + + var ( + resourceIdBeforeRecreate string + resourceIdAfterRecreate string + ) // Test Wired Network Group Assignment resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Creating a network group assignment + // Creating { Config: provider.ProviderConfig + ` resource "uxi_group" "my_group" { @@ -147,6 +202,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { group_id = uxi_group.my_group.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_network_group_assignment.my_network_group_assignment", "network_id", @@ -156,19 +212,30 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { "uxi_network_group_assignment.my_network_group_assignment", "group_id", func(group_id string) error { - st.Assert(t, group_id, util.GetGroupByName(groupName).Id) + assert.Equal(t, group_id, util.GetGroupByName(groupName).Id) return nil }, ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_network_group_assignment.my_network_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdBeforeRecreate = rs.Primary.ID + return util.CheckStateAgainstNetworkGroupAssignment( + t, + "uxi_network_group_assignment.my_network_group_assignment", + util.GetNetworkGroupAssignment(resourceIdBeforeRecreate), + )(s) + }, ), }, - // ImportState testing + // ImportState { ResourceName: "uxi_network_group_assignment.my_network_group_assignment", ImportState: true, ImportStateVerify: true, }, - // Update and Read testing + // Update { Config: provider.ProviderConfig + ` // the original resources @@ -196,6 +263,7 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { group_id = uxi_group.my_group_2.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_network_group_assignment.my_network_group_assignment", "network_id", @@ -205,7 +273,27 @@ func TestNetworkGroupAssignmentResourceForWirelessNetwork(t *testing.T) { "uxi_network_group_assignment.my_network_group_assignment", "group_id", func(group_id string) error { - st.Assert(t, group_id, util.GetGroupByName(group2Name).Id) + assert.Equal(t, group_id, util.GetGroupByName(group2Name).Id) + return nil + }, + ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_network_group_assignment.my_network_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdAfterRecreate = rs.Primary.ID + return util.CheckStateAgainstNetworkGroupAssignment( + t, + "uxi_network_group_assignment.my_network_group_assignment", + util.GetNetworkGroupAssignment(resourceIdAfterRecreate), + )(s) + }, + // Check that resource has been recreated + resource.TestCheckResourceAttrWith( + "uxi_network_group_assignment.my_network_group_assignment", + "id", + func(value string) error { + assert.NotEqual(t, value, resourceIdBeforeRecreate) return nil }, ), @@ -223,5 +311,12 @@ 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) + return nil + }, }) } diff --git a/test/live/resources/sensor_group_assignment_test.go b/test/live/resources/sensor_group_assignment_test.go index 938af090..194bc2f8 100644 --- a/test/live/resources/sensor_group_assignment_test.go +++ b/test/live/resources/sensor_group_assignment_test.go @@ -7,18 +7,26 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/util" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" ) func TestSensorGroupAssignmentResource(t *testing.T) { - const groupName = "tf_provider_acceptance_test_sensor_assignment_test" - const group2Name = "tf_provider_acceptance_test_sensor_assignment_test_two" - existingSensorProperties := util.GetSensorProperties(config.SensorId) + const ( + groupName = "tf_provider_acceptance_test_sensor_assignment_resource" + group2Name = "tf_provider_acceptance_test_sensor_assignment_resource_two" + ) + + var ( + existingSensorProperties = util.GetSensorProperties(config.SensorId) + resourceIdBeforeRecreate string + resourceIdAfterRecreate string + ) resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Creating a sensor group assignment + // Creating { Config: provider.ProviderConfig + ` resource "uxi_group" "my_group" { @@ -42,6 +50,7 @@ func TestSensorGroupAssignmentResource(t *testing.T) { group_id = uxi_group.my_group.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_sensor_group_assignment.my_sensor_group_assignment", "sensor_id", @@ -51,19 +60,30 @@ func TestSensorGroupAssignmentResource(t *testing.T) { "uxi_sensor_group_assignment.my_sensor_group_assignment", "group_id", func(value string) error { - st.Assert(t, value, util.GetGroupByName(groupName).Id) + assert.Equal(t, value, util.GetGroupByName(groupName).Id) return nil }, ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_sensor_group_assignment.my_sensor_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdBeforeRecreate = rs.Primary.ID + return util.CheckStateAgainstSensorGroupAssignment( + t, + "uxi_sensor_group_assignment.my_sensor_group_assignment", + util.GetSensorGroupAssignment(resourceIdBeforeRecreate), + )(s) + }, ), }, - // ImportState testing + // ImportState { ResourceName: "uxi_sensor_group_assignment.my_sensor_group_assignment", ImportState: true, ImportStateVerify: true, }, - // Update and Read testing + // Update { Config: provider.ProviderConfig + ` // the original resources @@ -89,6 +109,7 @@ func TestSensorGroupAssignmentResource(t *testing.T) { group_id = uxi_group.my_group_2.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_sensor_group_assignment.my_sensor_group_assignment", "sensor_id", @@ -98,10 +119,21 @@ func TestSensorGroupAssignmentResource(t *testing.T) { "uxi_sensor_group_assignment.my_sensor_group_assignment", "group_id", func(value string) error { - st.Assert(t, value, util.GetGroupByName(group2Name).Id) + assert.Equal(t, value, util.GetGroupByName(group2Name).Id) return nil }, ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_sensor_group_assignment.my_sensor_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdAfterRecreate = rs.Primary.ID + return util.CheckStateAgainstSensorGroupAssignment( + t, + "uxi_sensor_group_assignment.my_sensor_group_assignment", + util.GetSensorGroupAssignment(resourceIdAfterRecreate), + )(s) + }, ), }, // Delete sensor-group assignments and remove sensors from state @@ -116,5 +148,12 @@ 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) + return nil + }, }) } diff --git a/test/live/resources/service_test_group_assignment_test.go b/test/live/resources/service_test_group_assignment_test.go index 74ffc26e..99c4f80c 100644 --- a/test/live/resources/service_test_group_assignment_test.go +++ b/test/live/resources/service_test_group_assignment_test.go @@ -7,17 +7,25 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/util" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" ) func TestServiceTestGroupAssignmentResource(t *testing.T) { - const groupName = "tf_acceptance_test_service_test_group_assignment" - const group2Name = "tf_acceptance_test_service_test_group_assignment_two" + const ( + groupName = "tf_acceptance_test_service_test_group_assignment_resource" + group2Name = "tf_acceptance_test_service_test_group_assignment_resource_two" + ) + + var ( + resourceIdBeforeRecreate string + resourceIdAfterRecreate string + ) resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Creating a serviceTest group assignment + // Creating { Config: provider.ProviderConfig + ` resource "uxi_group" "my_group" { @@ -38,6 +46,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { group_id = uxi_group.my_group.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_service_test_group_assignment.my_service_test_group_assignment", "service_test_id", @@ -47,19 +56,30 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { "uxi_service_test_group_assignment.my_service_test_group_assignment", "group_id", func(value string) error { - st.Assert(t, value, util.GetGroupByName(groupName).Id) + assert.Equal(t, value, util.GetGroupByName(groupName).Id) return nil }, ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_service_test_group_assignment.my_service_test_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdBeforeRecreate = rs.Primary.ID + return util.CheckStateAgainstServiceTestGroupAssignment( + t, + "uxi_service_test_group_assignment.my_service_test_group_assignment", + util.GetServiceTestGroupAssignment(rs.Primary.ID), + )(s) + }, ), }, - // ImportState testing + // ImportState { ResourceName: "uxi_service_test_group_assignment.my_service_test_group_assignment", ImportState: true, ImportStateVerify: true, }, - // Update and Read testing + // Update { Config: provider.ProviderConfig + ` // the original resources @@ -82,6 +102,7 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { group_id = uxi_group.my_group_2.id }`, Check: resource.ComposeAggregateTestCheckFunc( + // Check configured properties resource.TestCheckResourceAttr( "uxi_service_test_group_assignment.my_service_test_group_assignment", "service_test_id", @@ -91,7 +112,27 @@ func TestServiceTestGroupAssignmentResource(t *testing.T) { "uxi_service_test_group_assignment.my_service_test_group_assignment", "group_id", func(value string) error { - st.Assert(t, value, util.GetGroupByName(group2Name).Id) + assert.Equal(t, value, util.GetGroupByName(group2Name).Id) + return nil + }, + ), + // Check properties match what is on backend + func(s *terraform.State) error { + resourceName := "uxi_service_test_group_assignment.my_service_test_group_assignment" + rs := s.RootModule().Resources[resourceName] + resourceIdAfterRecreate = rs.Primary.ID + return util.CheckStateAgainstServiceTestGroupAssignment( + t, + "uxi_service_test_group_assignment.my_service_test_group_assignment", + util.GetServiceTestGroupAssignment(rs.Primary.ID), + )(s) + }, + // Check that resource has been recreated + resource.TestCheckResourceAttrWith( + "uxi_service_test_group_assignment.my_service_test_group_assignment", + "id", + func(value string) error { + assert.NotEqual(t, value, resourceIdBeforeRecreate) return nil }, ), @@ -109,5 +150,12 @@ 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) + return nil + }, }) } diff --git a/test/live/util/agent.go b/test/live/util/agent.go index b1f741e1..58f5e8de 100644 --- a/test/live/util/agent.go +++ b/test/live/util/agent.go @@ -8,12 +8,13 @@ import ( "fmt" "io" "net/http" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/config" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func GetAgentProperties(id string) config_api_client.AgentItem { @@ -30,7 +31,10 @@ func GetAgentProperties(id string) config_api_client.AgentItem { return result.Items[0] } -func CheckStateAgainstAgent(t st.Fatalf, agent config_api_client.AgentItem) resource.TestCheckFunc { +func CheckStateAgainstAgent( + t *testing.T, + agent config_api_client.AgentItem, +) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.uxi_agent.my_agent", "id", config.AgentPermanentId), resource.TestCheckResourceAttr("data.uxi_agent.my_agent", "serial", agent.Serial), @@ -39,7 +43,7 @@ func CheckStateAgainstAgent(t st.Fatalf, agent config_api_client.AgentItem) reso "data.uxi_agent.my_agent", "name", func(value string) error { - st.Assert(t, value, agent.Name) + assert.Equal(t, value, agent.Name) return nil }, ), @@ -135,3 +139,17 @@ func (p ProvisionAgent) generateId() (string, error) { return uuid.String(), nil } + +func GetAgent(id string) *config_api_client.AgentItem { + result, _, err := Client.ConfigurationAPI. + AgentsGet(context.Background()). + Id(id). + Execute() + if err != nil { + panic(err) + } + if len(result.Items) != 1 { + return nil + } + return &result.Items[0] +} diff --git a/test/live/util/agent_group_assignment.go b/test/live/util/agent_group_assignment.go index 9f95f13f..268cf5b6 100644 --- a/test/live/util/agent_group_assignment.go +++ b/test/live/util/agent_group_assignment.go @@ -2,13 +2,13 @@ package util import ( "context" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" ) -func GetAgentGroupAssignment(id string) config_api_client.AgentGroupAssignmentsItem { +func GetAgentGroupAssignment(id string) *config_api_client.AgentGroupAssignmentsItem { result, _, err := Client.ConfigurationAPI. AgentGroupAssignmentsGet(context.Background()). Id(id). @@ -17,13 +17,13 @@ func GetAgentGroupAssignment(id string) config_api_client.AgentGroupAssignmentsI panic(err) } if len(result.Items) != 1 { - panic("agent_group_assignment with id `" + id + "` could not be found") + return nil } - return result.Items[0] + return &result.Items[0] } func CheckStateAgainstAgentGroupAssignment( - t st.Fatalf, + t *testing.T, entity string, agentGroupAssignment config_api_client.AgentGroupAssignmentsItem, ) resource.TestCheckFunc { diff --git a/test/live/util/network_group_assignment.go b/test/live/util/network_group_assignment.go index 3ef454c0..8f0487af 100644 --- a/test/live/util/network_group_assignment.go +++ b/test/live/util/network_group_assignment.go @@ -2,10 +2,10 @@ package util import ( "context" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" ) func GetNetworkGroupAssignment(id string) config_api_client.NetworkGroupAssignmentsItem { @@ -23,7 +23,7 @@ func GetNetworkGroupAssignment(id string) config_api_client.NetworkGroupAssignme } func CheckStateAgainstNetworkGroupAssignment( - t st.Fatalf, + t *testing.T, entity string, networkGroupAssignment config_api_client.NetworkGroupAssignmentsItem, ) resource.TestCheckFunc { diff --git a/test/live/util/sensor.go b/test/live/util/sensor.go index bcb9fa26..50f9aa4b 100644 --- a/test/live/util/sensor.go +++ b/test/live/util/sensor.go @@ -2,11 +2,12 @@ package util import ( "context" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/config" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func GetSensorProperties(id string) config_api_client.SensorItem { @@ -24,7 +25,7 @@ func GetSensorProperties(id string) config_api_client.SensorItem { } func CheckDataSourceStateAgainstSensor( - t st.Fatalf, + t *testing.T, entity string, sensor config_api_client.SensorItem, ) resource.TestCheckFunc { @@ -36,7 +37,7 @@ func CheckDataSourceStateAgainstSensor( entity, "name", func(value string) error { - st.Assert(t, value, sensor.Name) + assert.Equal(t, value, sensor.Name) return nil }, ), @@ -51,7 +52,7 @@ func CheckDataSourceStateAgainstSensor( } func CheckResourceStateAgainstSensor( - t st.Fatalf, + t *testing.T, entity string, sensor config_api_client.SensorItem, ) resource.TestCheckFunc { @@ -61,7 +62,7 @@ func CheckResourceStateAgainstSensor( entity, "name", func(value string) error { - st.Assert(t, value, sensor.Name) + assert.Equal(t, value, sensor.Name) return nil }, ), diff --git a/test/live/util/sensor_group_assignment.go b/test/live/util/sensor_group_assignment.go index 801dae2c..66661e09 100644 --- a/test/live/util/sensor_group_assignment.go +++ b/test/live/util/sensor_group_assignment.go @@ -2,10 +2,10 @@ package util import ( "context" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" ) func GetSensorGroupAssignment(id string) config_api_client.SensorGroupAssignmentsItem { @@ -23,7 +23,7 @@ func GetSensorGroupAssignment(id string) config_api_client.SensorGroupAssignment } func CheckStateAgainstSensorGroupAssignment( - t st.Fatalf, + t *testing.T, entity string, sensorGroupAssignment config_api_client.SensorGroupAssignmentsItem, ) resource.TestCheckFunc { diff --git a/test/live/util/service.go b/test/live/util/service.go index eed04f48..14529742 100644 --- a/test/live/util/service.go +++ b/test/live/util/service.go @@ -3,11 +3,11 @@ package util import ( "context" "strconv" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/config" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" ) func GetServiceTest(id string) config_api_client.ServiceTestsListItem { @@ -25,7 +25,7 @@ func GetServiceTest(id string) config_api_client.ServiceTestsListItem { } func CheckStateAgainstServiceTest( - t st.Fatalf, + t *testing.T, serviceTest config_api_client.ServiceTestsListItem, ) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( diff --git a/test/live/util/service_test_group_assignment.go b/test/live/util/service_test_group_assignment.go index 24c546ec..30d117ff 100644 --- a/test/live/util/service_test_group_assignment.go +++ b/test/live/util/service_test_group_assignment.go @@ -2,10 +2,10 @@ package util import ( "context" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" ) func GetServiceTestGroupAssignment(id string) config_api_client.ServiceTestGroupAssignmentsItem { @@ -23,7 +23,7 @@ func GetServiceTestGroupAssignment(id string) config_api_client.ServiceTestGroup } func CheckStateAgainstServiceTestGroupAssignment( - t st.Fatalf, + t *testing.T, entity string, serviceTestGroupAssignment config_api_client.ServiceTestGroupAssignmentsItem, ) resource.TestCheckFunc { diff --git a/test/live/util/util.go b/test/live/util/util.go index aa7d8b1b..3430656c 100644 --- a/test/live/util/util.go +++ b/test/live/util/util.go @@ -4,9 +4,9 @@ import ( "fmt" "math" "strconv" + "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" ) func ConditionalProperty(property string, value *string) string { @@ -17,7 +17,7 @@ func ConditionalProperty(property string, value *string) string { } func TestOptionalValue( - t st.Fatalf, + t *testing.T, tfResource string, tfKey string, property *string, @@ -26,22 +26,13 @@ func TestOptionalValue( return resource.TestCheckNoResourceAttr(tfResource, tfKey) } - return resource.TestCheckResourceAttrWith( - tfResource, - tfKey, - func(value string) error { - if value != *property { - return fmt.Errorf("have `%s`; but want `%s`", value, *property) - } - return nil - }, - ) + return resource.TestCheckResourceAttrPtr(tfResource, tfKey, property) } // This is required to do a check against floats since 100% accuracy is not guaranteed for floating // point numbers in the terraform plugin framework func TestOptionalFloatValue( - t st.Fatalf, + t *testing.T, tfResource string, tfKey string, property *float32, @@ -55,8 +46,8 @@ func TestOptionalFloatValue( tfResource, tfKey, func(value string) error { - have := math.Round(stringToFloat64(value)*1e6) / 1e6 - want := math.Round(float64(*property*1e6)) / 1e6 + have := math.Round(stringToFloat64(value)*1e5) / 1e5 + want := math.Round(float64(*property*1e5)) / 1e5 if have != want { return fmt.Errorf("have `%f`; but want `%f`", have, want) } diff --git a/test/live/util/wired_network.go b/test/live/util/wired_network.go index 399224f4..e8354ba9 100644 --- a/test/live/util/wired_network.go +++ b/test/live/util/wired_network.go @@ -3,11 +3,12 @@ package util import ( "context" "strconv" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/config" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func GetWiredNetwork(id string) config_api_client.WiredNetworksItem { @@ -25,7 +26,7 @@ func GetWiredNetwork(id string) config_api_client.WiredNetworksItem { } func CheckStateAgainstWiredNetwork( - t st.Fatalf, + t *testing.T, wired_network config_api_client.WiredNetworksItem, ) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( @@ -38,7 +39,7 @@ func CheckStateAgainstWiredNetwork( "data.uxi_wired_network.my_wired_network", "name", func(value string) error { - st.Assert(t, value, wired_network.Name) + assert.Equal(t, value, wired_network.Name) return nil }, ), diff --git a/test/live/util/wireless_network.go b/test/live/util/wireless_network.go index f2b15eea..d2d94138 100644 --- a/test/live/util/wireless_network.go +++ b/test/live/util/wireless_network.go @@ -3,11 +3,12 @@ package util import ( "context" "strconv" + "testing" config_api_client "github.com/aruba-uxi/terraform-provider-hpeuxi/pkg/config-api-client" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/live/config" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func GetWirelessNetwork(id string) config_api_client.WirelessNetworksItem { @@ -25,7 +26,7 @@ func GetWirelessNetwork(id string) config_api_client.WirelessNetworksItem { } func CheckStateAgainstWirelessNetwork( - t st.Fatalf, + t *testing.T, wireless_network config_api_client.WirelessNetworksItem, ) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( @@ -43,7 +44,7 @@ func CheckStateAgainstWirelessNetwork( "data.uxi_wireless_network.my_wireless_network", "name", func(value string) error { - st.Assert(t, value, wireless_network.Name) + assert.Equal(t, value, wireless_network.Name) return nil }, ), diff --git a/test/mocked/datasources/agent_group_assignment_test.go b/test/mocked/datasources/agent_group_assignment_test.go index c7ff292b..d08924ea 100644 --- a/test/mocked/datasources/agent_group_assignment_test.go +++ b/test/mocked/datasources/agent_group_assignment_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestAgentGroupAssignmentDataSource(t *testing.T) { @@ -103,7 +103,7 @@ func TestAgentGroupAssignmentDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/agent_test.go b/test/mocked/datasources/agent_test.go index d79a89a5..a77bdcfa 100644 --- a/test/mocked/datasources/agent_test.go +++ b/test/mocked/datasources/agent_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestAgentDataSource(t *testing.T) { @@ -101,7 +101,7 @@ func TestAgentDataSourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.uxi_agent.my_agent", "id", "id"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/group_test.go b/test/mocked/datasources/group_test.go index b6c3f646..da85c401 100644 --- a/test/mocked/datasources/group_test.go +++ b/test/mocked/datasources/group_test.go @@ -12,7 +12,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestGroupDataSource(t *testing.T) { @@ -115,7 +115,7 @@ func TestGroupDataSourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.uxi_group.my_group", "id", "id"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/network_group_assignment_test.go b/test/mocked/datasources/network_group_assignment_test.go index f0a60c4d..c925e5e3 100644 --- a/test/mocked/datasources/network_group_assignment_test.go +++ b/test/mocked/datasources/network_group_assignment_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestNetworkGroupAssignmentDataSource(t *testing.T) { @@ -103,7 +103,7 @@ func TestNetworkGroupAssignmentDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/sensor_group_assignment_test.go b/test/mocked/datasources/sensor_group_assignment_test.go index 8165508b..b234e836 100644 --- a/test/mocked/datasources/sensor_group_assignment_test.go +++ b/test/mocked/datasources/sensor_group_assignment_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestSensorGroupAssignmentDataSource(t *testing.T) { @@ -103,7 +103,7 @@ func TestSensorGroupAssignmentDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/sensor_test.go b/test/mocked/datasources/sensor_test.go index 4f1124c5..5a6e5e21 100644 --- a/test/mocked/datasources/sensor_test.go +++ b/test/mocked/datasources/sensor_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestSensorDataSource(t *testing.T) { @@ -112,7 +112,7 @@ func TestSensorDataSourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.uxi_sensor.my_sensor", "id", "id"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/service_test.go b/test/mocked/datasources/service_test.go index 8ae8b3ae..b03a2926 100644 --- a/test/mocked/datasources/service_test.go +++ b/test/mocked/datasources/service_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestServiceTestDataSource(t *testing.T) { @@ -119,7 +119,7 @@ func TestServiceTestDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) 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 94ae56a3..a0984356 100644 --- a/test/mocked/datasources/service_test_group_assignment_test.go +++ b/test/mocked/datasources/service_test_group_assignment_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestServiceTestGroupAssignmentDataSource(t *testing.T) { @@ -103,7 +103,7 @@ func TestServiceTestGroupAssignmentDataSourceTooManyRequestsHandling(t *testing. "id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/wired_network_test.go b/test/mocked/datasources/wired_network_test.go index bb8d4221..6952d43d 100644 --- a/test/mocked/datasources/wired_network_test.go +++ b/test/mocked/datasources/wired_network_test.go @@ -7,11 +7,10 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/mocked/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/mocked/util" - "github.com/nbio/st" - "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" ) func TestWiredNetworkDataSource(t *testing.T) { @@ -130,7 +129,7 @@ func TestWiredNetworkDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/datasources/wireless_network_test.go b/test/mocked/datasources/wireless_network_test.go index 2813a5be..10bcdbe1 100644 --- a/test/mocked/datasources/wireless_network_test.go +++ b/test/mocked/datasources/wireless_network_test.go @@ -7,11 +7,10 @@ import ( "github.com/aruba-uxi/terraform-provider-hpeuxi/test/mocked/provider" "github.com/aruba-uxi/terraform-provider-hpeuxi/test/mocked/util" - "github.com/nbio/st" - "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" ) func TestWirelessNetworkDataSource(t *testing.T) { @@ -144,7 +143,7 @@ func TestWirelessNetworkDataSourceTooManyRequestsHandling(t *testing.T) { "id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/resources/agent_group_assignment_test.go b/test/mocked/resources/agent_group_assignment_test.go index 183959af..12b7914d 100644 --- a/test/mocked/resources/agent_group_assignment_test.go +++ b/test/mocked/resources/agent_group_assignment_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestAgentGroupAssignmentResource(t *testing.T) { @@ -445,7 +445,7 @@ func TestAgentGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { "agent_group_assignment_id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), @@ -474,7 +474,7 @@ func TestAgentGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { ImportState: true, ImportStateVerify: true, Check: func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, }, @@ -521,7 +521,7 @@ func TestAgentGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { }, Config: provider.ProviderConfig, Check: func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, }, diff --git a/test/mocked/resources/agent_test.go b/test/mocked/resources/agent_test.go index 86a921bd..638095de 100644 --- a/test/mocked/resources/agent_test.go +++ b/test/mocked/resources/agent_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-plugin-testing/tfversion" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestAgentResource(t *testing.T) { @@ -173,7 +173,7 @@ func TestAgentResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("uxi_agent.my_agent", "id", "id"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), @@ -217,7 +217,7 @@ func TestAgentResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("uxi_agent.my_agent", "name", "name_2"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), @@ -238,7 +238,7 @@ func TestAgentResourceTooManyRequestsHandling(t *testing.T) { Config: provider.ProviderConfig, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/resources/group_test.go b/test/mocked/resources/group_test.go index b9bfb286..390840fe 100644 --- a/test/mocked/resources/group_test.go +++ b/test/mocked/resources/group_test.go @@ -11,7 +11,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) type Fetcher interface { @@ -373,7 +373,7 @@ func TestGroupResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("uxi_group.my_group", "id", "id"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), @@ -426,7 +426,7 @@ func TestGroupResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("uxi_group.my_group", "name", "name_2"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/resources/network_group_assignment_test.go b/test/mocked/resources/network_group_assignment_test.go index 06a6d80a..45749cac 100644 --- a/test/mocked/resources/network_group_assignment_test.go +++ b/test/mocked/resources/network_group_assignment_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestNetworkGroupAssignmentResourceForWiredNetwork(t *testing.T) { @@ -811,7 +811,7 @@ func TestNetworkGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { "network_id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), @@ -865,7 +865,7 @@ func TestNetworkGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/resources/sensor_group_assignment_test.go b/test/mocked/resources/sensor_group_assignment_test.go index 7f27bcef..53969ef7 100644 --- a/test/mocked/resources/sensor_group_assignment_test.go +++ b/test/mocked/resources/sensor_group_assignment_test.go @@ -10,7 +10,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestSensorGroupAssignmentResource(t *testing.T) { @@ -439,7 +439,7 @@ func TestSensorGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { "sensor_group_assignment_id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), @@ -494,7 +494,7 @@ func TestSensorGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) { }`, Check: resource.ComposeAggregateTestCheckFunc( func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), diff --git a/test/mocked/resources/sensor_test.go b/test/mocked/resources/sensor_test.go index 9dd373c1..17990635 100644 --- a/test/mocked/resources/sensor_test.go +++ b/test/mocked/resources/sensor_test.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-plugin-testing/tfversion" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestSensorResource(t *testing.T) { @@ -194,7 +194,7 @@ func TestSensorResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("uxi_sensor.my_sensor", "id", "id"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ), @@ -233,7 +233,7 @@ func TestSensorResourceTooManyRequestsHandling(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("uxi_sensor.my_sensor", "name", "name_2"), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) 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 42762e24..f70e7c6c 100644 --- a/test/mocked/resources/service_test_group_assignment_test.go +++ b/test/mocked/resources/service_test_group_assignment_test.go @@ -11,7 +11,7 @@ import ( "github.com/h2non/gock" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/nbio/st" + "github.com/stretchr/testify/assert" ) func TestServiceTestGroupAssignmentResource(t *testing.T) { @@ -405,7 +405,7 @@ func TestServiceTestGroupAssignmentResourceTooManyRequestsHandling(t *testing.T) "service_test_group_assignment_id", ), func(s *terraform.State) error { - st.Assert(t, mockTooManyRequests.Mock.Request().Counter, 0) + assert.Equal(t, mockTooManyRequests.Mock.Request().Counter, 0) return nil }, ),