From 72102d8dddc12bd5ec42c1a42fe3ec8eb025aab1 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Fri, 25 Oct 2024 16:36:36 -0700 Subject: [PATCH] `networkmanager` --- .../service/networkmanager/connection_test.go | 17 +++-------------- .../service/networkmanager/device_test.go | 19 ++++--------------- internal/service/networkmanager/link_test.go | 17 +++-------------- internal/service/networkmanager/site_test.go | 19 ++++--------------- 4 files changed, 14 insertions(+), 58 deletions(-) diff --git a/internal/service/networkmanager/connection_test.go b/internal/service/networkmanager/connection_test.go index eacc5ce7aaf..8e86b50a79b 100644 --- a/internal/service/networkmanager/connection_test.go +++ b/internal/service/networkmanager/connection_test.go @@ -56,7 +56,7 @@ func testAccConnection_basic(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccConnectionImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, }, @@ -108,7 +108,7 @@ func testAccConnection_tags(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccConnectionImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -157,7 +157,7 @@ func testAccConnection_descriptionAndLinks(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccConnectionImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -397,14 +397,3 @@ resource "aws_networkmanager_connection" "test" { } `, rName)) } - -func testAccConnectionImportStateIdFunc(resourceName string) resource.ImportStateIdFunc { - return func(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return "", fmt.Errorf("Not found: %s", resourceName) - } - - return rs.Primary.Attributes[names.AttrARN], nil - } -} diff --git a/internal/service/networkmanager/device_test.go b/internal/service/networkmanager/device_test.go index fec233fb948..5bca425fd97 100644 --- a/internal/service/networkmanager/device_test.go +++ b/internal/service/networkmanager/device_test.go @@ -48,7 +48,7 @@ func TestAccNetworkManagerDevice_basic(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccDeviceImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, }, @@ -100,7 +100,7 @@ func TestAccNetworkManagerDevice_tags(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccDeviceImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -156,7 +156,7 @@ func TestAccNetworkManagerDevice_allAttributes(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccDeviceImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -203,7 +203,7 @@ func TestAccNetworkManagerDevice_awsLocation(t *testing.T) { // nosemgrep:ci.aws { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccDeviceImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -488,14 +488,3 @@ resource "aws_networkmanager_device" "test" { } `, rName)) } - -func testAccDeviceImportStateIdFunc(resourceName string) resource.ImportStateIdFunc { - return func(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return "", fmt.Errorf("Not found: %s", resourceName) - } - - return rs.Primary.Attributes[names.AttrARN], nil - } -} diff --git a/internal/service/networkmanager/link_test.go b/internal/service/networkmanager/link_test.go index 19cf568702a..dccbde221ae 100644 --- a/internal/service/networkmanager/link_test.go +++ b/internal/service/networkmanager/link_test.go @@ -46,7 +46,7 @@ func TestAccNetworkManagerLink_basic(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccLinkImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, }, @@ -98,7 +98,7 @@ func TestAccNetworkManagerLink_tags(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccLinkImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -148,7 +148,7 @@ func TestAccNetworkManagerLink_allAttributes(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccLinkImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -376,14 +376,3 @@ resource "aws_networkmanager_link" "test" { } `, rName) } - -func testAccLinkImportStateIdFunc(resourceName string) resource.ImportStateIdFunc { - return func(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return "", fmt.Errorf("Not found: %s", resourceName) - } - - return rs.Primary.Attributes[names.AttrARN], nil - } -} diff --git a/internal/service/networkmanager/site_test.go b/internal/service/networkmanager/site_test.go index ae7a6bf667d..d69862e3ee8 100644 --- a/internal/service/networkmanager/site_test.go +++ b/internal/service/networkmanager/site_test.go @@ -42,7 +42,7 @@ func TestAccNetworkManagerSite_basic(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccSiteImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, }, @@ -94,7 +94,7 @@ func TestAccNetworkManagerSite_tags(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccSiteImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -139,7 +139,7 @@ func TestAccNetworkManagerSite_description(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccSiteImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -177,7 +177,7 @@ func TestAccNetworkManagerSite_location(t *testing.T) { { ResourceName: resourceName, ImportState: true, - ImportStateIdFunc: testAccSiteImportStateIdFunc(resourceName), + ImportStateIdFunc: acctest.AttrImportStateIdFunc(resourceName, names.AttrARN), ImportStateVerify: true, }, { @@ -356,14 +356,3 @@ resource "aws_networkmanager_site" "test" { } `, rName) } - -func testAccSiteImportStateIdFunc(resourceName string) resource.ImportStateIdFunc { - return func(s *terraform.State) (string, error) { - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return "", fmt.Errorf("Not found: %s", resourceName) - } - - return rs.Primary.Attributes[names.AttrARN], nil - } -}