Skip to content

Commit

Permalink
Replace panic(err) with t.Error(err)
Browse files Browse the repository at this point in the history
Some tests have panic() calls in their PreConfig stage. That halts then
entire test suite execution.
Using t.Error() will let test execution resume while marking the test as
failed.

Signed-off-by: Kobi Samoray <[email protected]>
  • Loading branch information
ksamoray committed Dec 6, 2023
1 parent 92dc814 commit c1e2949
Show file tree
Hide file tree
Showing 35 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_firewall_section_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccDataSourceNsxtFirewallSection_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtFirewallSectionCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNSXFirewallSectionReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_logical_tier1_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccDataSourceNsxtLogicalTier1Router_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtTier1RouterCreate(routerName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNSXTier1RouterReadTemplate(routerName),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_ns_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccDataSourceNsxtNsGroup_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtNsGroupCreate(groupName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNSXNsGroupReadTemplate(groupName),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_ns_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAccDataSourceNsxtNsGroups_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtNsGroupCreate(groupName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNSXNsGroupsReadTemplate(groupName),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_ns_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccDataSourceNsxtNsService_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtNsServiceCreate(serviceName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNSXNsServiceReadTemplate(serviceName),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_ns_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAccDataSourceNsxtNsServices_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtNsServiceCreate(serviceName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNSXNsServicesReadTemplate(serviceName),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_bfd_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAccDataSourceNsxtPolicyBfdProfile_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyBfdProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyBfdProfileReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_bridge_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAccDataSourceNsxtPolicyBridgeProfile_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyBridgeProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyBridgeProfileReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_gateway_qos_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func testAccDataSourceNsxtPolicyGatewayQosProfileBasic(t *testing.T, withContext
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyGatewayQosProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyGatewayQosProfileReadTemplate(name, withContext),
Expand Down
4 changes: 2 additions & 2 deletions nsxt/data_source_nsxt_policy_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func testAccDataSourceNsxtPolicyGroupBasic(t *testing.T, withContext bool, preCh
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyGroupCreate(domain, name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyGroupReadTemplate(domain, name, withContext),
Expand Down Expand Up @@ -76,7 +76,7 @@ func TestAccDataSourceNsxtPolicyGroup_withSite(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyGroupCreate(domain, name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyGroupReadTemplate(domain, name, false),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ip_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func testAccDataSourceNsxtPolicyIPBlockBasic(t *testing.T, withContext bool, pre
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyIPBlockCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyIPBlockReadTemplate(name, withContext),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ip_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func testAccDataSourceNsxtPolicyIPPoolBasic(t *testing.T, withContext bool, preC
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyIPPoolCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyIPPoolReadTemplate(name, withContext),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ipv6_dad_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func testAccDataSourceNsxtPolicyIpv6DadProfileBasic(t *testing.T, withContext bo
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyIpv6DadProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyIpv6DadProfileReadTemplate(name, withContext),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ipv6_ndra_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func testAccDataSourceNsxtPolicyIpv6NdraProfileBasic(t *testing.T, withContext b
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyIpv6NdraProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyIpv6NdraProfileReadTemplate(name, withContext),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_lb_app_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAccDataSourceNsxtPolicyLBAppProfile_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyLBAppProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyLBAppProfileReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_lb_client_ssl_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccDataSourceNsxtPolicyLBClientSslProfile_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyLBClientSslProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyLBClientSslProfileReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_lb_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAccDataSourceNsxtPolicyLBMonitor_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyLBMonitorCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyLBMonitorReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_lb_server_ssl_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccDataSourceNsxtPolicyLBServerSslProfile_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyLBServerSslProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyLBServerSslProfileReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAccDataSourceNsxtPolicyProject_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyProjectCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyProjectReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_qos_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func testAccDataSourceNsxtPolicyQosProfileBasic(t *testing.T, withContext bool,
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyQosProfileCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyQosProfileReadTemplate(name, withContext),
Expand Down
4 changes: 2 additions & 2 deletions nsxt/data_source_nsxt_policy_realization_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func testAccDataSourceNsxtPolicyRealizationInfoTier1DataSource(t *testing.T, wit
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyTier1GatewayCreate(resourceName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyRealizationInfoReadDataSourceTemplate(resourceDataType, resourceName, entityType, withContext),
Expand Down Expand Up @@ -86,7 +86,7 @@ func testAccDataSourceNsxtPolicyRealizationInfoTier1DataSourceEntity(t *testing.
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyTier1GatewayCreate(resourceName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyRealizationInfoReadDataSourceTemplate(resourceDataType, resourceName, entityType, withContext),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func testAccDataSourceNsxtPolicySegmentBasic(t *testing.T, withContext bool, pre
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicySegmentCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicySegmentReadTemplate(name, withContext),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_tier0_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAccDataSourceNsxtPolicyTier0Gateway_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyTier0GatewayCreate(name); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyTier0GatewayReadTemplate(name),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_tier1_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func testAccDataSourceNsxtPolicyTier1GatewayBasic(t *testing.T, withContext bool
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyTier1GatewayCreate(routerName); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyTier1ReadTemplate(routerName, withContext),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_vni_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAccDataSourceNsxtPolicyVniPoolConfig_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyVniPoolConfigReadTemplate(),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_switching_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAccDataSourceNsxtSwitchingProfile_basic(t *testing.T) {
{
PreConfig: func() {
if err := testAccDataSourceNsxtSwitchingProfileCreate(profileName, profileType); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNSXSwitchingProfileReadTemplate(profileName),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_logical_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestAccResourceNsxtLogicalPort_withProfiles(t *testing.T) {
PreConfig: func() {
// Create a custom switching profile
if err := testAccDataSourceNsxtSwitchingProfileCreate(customProfileName, profileType); err != nil {
panic(err)
t.Error(err)
}
},
// Create a logical port to use the custom switching profile
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_logical_switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestAccResourceNsxtLogicalSwitch_withProfiles(t *testing.T) {
PreConfig: func() {
// Create a custom switching profile
if err := testAccDataSourceNsxtSwitchingProfileCreate(customProfileName, profileType); err != nil {
panic(err)
t.Error(err)
}
},
// Create a logical switch to use the custom switching profile
Expand Down
12 changes: 6 additions & 6 deletions nsxt/resource_nsxt_policy_evpn_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func TestAccResourceNsxtPolicyEvpnConfig_inline(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
if err := testAccDataSourceNsxtPolicyVniPoolConfigDelete(); err != nil {
panic(err)
t.Error(err)
}
return testAccNsxtPolicyEvpnConfigCheckDestroy(state, displayName)
},
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyEvpnConfigInline(displayName, description, true),
Expand Down Expand Up @@ -80,15 +80,15 @@ func TestAccResourceNsxtPolicyEvpnConfig_routeServer(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
if err := testAccDataSourceNsxtPolicyVniPoolConfigDelete(); err != nil {
panic(err)
t.Error(err)
}
return testAccNsxtPolicyEvpnConfigCheckDestroy(state, displayName)
},
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyEvpnConfigRouteServer(displayName, description),
Expand Down Expand Up @@ -134,15 +134,15 @@ func TestAccResourceNsxtPolicyEvpnConfig_importBasic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
if err := testAccDataSourceNsxtPolicyVniPoolConfigDelete(); err != nil {
panic(err)
t.Error(err)
}
return testAccNsxtPolicyEvpnConfigCheckDestroy(state, name)
},
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyEvpnConfigInline(name, "", false),
Expand Down
8 changes: 4 additions & 4 deletions nsxt/resource_nsxt_policy_evpn_tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ func TestAccResourceNsxtPolicyEvpnTenant_basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
if err := testAccDataSourceNsxtPolicyVniPoolConfigDelete(); err != nil {
panic(err)
t.Error(err)
}
return testAccNsxtPolicyEvpnTenantCheckDestroy(state, accTestPolicyEvpnTenantUpdateAttributes["display_name"])
},
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyEvpnTenantCreate(),
Expand Down Expand Up @@ -83,15 +83,15 @@ func TestAccResourceNsxtPolicyEvpnTenant_importBasic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
if err := testAccDataSourceNsxtPolicyVniPoolConfigDelete(); err != nil {
panic(err)
t.Error(err)
}
return testAccNsxtPolicyEvpnTenantCheckDestroy(state, accTestPolicyEvpnTenantUpdateAttributes["display_name"])
},
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyEvpnTenantUpdate(),
Expand Down
8 changes: 4 additions & 4 deletions nsxt/resource_nsxt_policy_evpn_tunnel_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func TestAccResourceNsxtPolicyEvpnTunnelEndpoint_basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
if err := testAccDataSourceNsxtPolicyVniPoolConfigDelete(); err != nil {
panic(err)
t.Error(err)
}
return testAccNsxtPolicyEvpnTunnelEndpointCheckDestroy(state, accTestPolicyEvpnTunnelEndpointUpdateAttributes["display_name"])
},
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyEvpnTunnelEndpointBasic(true),
Expand Down Expand Up @@ -88,15 +88,15 @@ func TestAccResourceNsxtPolicyEvpnTunnelEndpoint_importBasic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
if err := testAccDataSourceNsxtPolicyVniPoolConfigDelete(); err != nil {
panic(err)
t.Error(err)
}
return testAccNsxtPolicyEvpnTunnelEndpointCheckDestroy(state, name)
},
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyVniPoolConfigCreate(); err != nil {
panic(err)
t.Error(err)
}
},
Config: testAccNsxtPolicyEvpnTunnelEndpointBasic(false),
Expand Down
Loading

0 comments on commit c1e2949

Please sign in to comment.