Skip to content

Commit

Permalink
chore: add import by addr test
Browse files Browse the repository at this point in the history
  • Loading branch information
ikadix committed Aug 12, 2024
1 parent 7049565 commit b50ab77
Show file tree
Hide file tree
Showing 3 changed files with 482 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
p8mwdmjy061s
begv003ejaf9
61 changes: 61 additions & 0 deletions internal/v6provider/resource_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,67 @@ func TestAccKatapultIP_minimal(t *testing.T) {
})
}

func TestAccKatapultIP_import_by_addr(t *testing.T) {

Check failure on line 128 in internal/v6provider/resource_ip_test.go

View workflow job for this annotation

GitHub Actions / Lint Provider

AT002: acceptance test function name should not include import
tt := newTestTools(t)

res, err := tt.Meta.Core.GetDataCenterDefaultNetworkWithResponse(tt.Ctx,
&core.GetDataCenterDefaultNetworkParams{
DataCenterPermalink: &tt.Meta.confDataCenter,
})
require.NoError(t, err)
require.NotNil(t, res)
require.NotNil(t, res.JSON200)

network := res.JSON200.Network
require.NotNil(t, network.Id)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: tt.ProviderFactories,

CheckDestroy: testAccCheckKatapultIPDestroy(tt),
Steps: []resource.TestStep{
{
Config: `resource "katapult_ip" "web" {}`,
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKatapultIPAttrs(tt, "katapult_ip.web"),
resource.TestCheckResourceAttr(
"katapult_ip.web", "network_id", *network.Id,
),
resource.TestMatchResourceAttr(
"katapult_ip.web",
"address", regexp.MustCompile(
`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`,
),
),
resource.TestCheckResourceAttr(
"katapult_ip.web", "version", "4",
),
resource.TestCheckResourceAttr(
"katapult_ip.web", "vip", "false",
),
resource.TestCheckResourceAttr(
"katapult_ip.web", "label", "",
),
),
},
{
ResourceName: "katapult_ip.web",
ImportStateIdFunc: func(s *terraform.State) (string, error) {
rs := s.RootModule().Resources["katapult_ip.web"]
if rs == nil {
return "", fmt.Errorf("resource not found")
}

return rs.Primary.Attributes["address"], nil
},
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccKatapultIP_ipv4(t *testing.T) {
tt := newTestTools(t)

Expand Down
Loading

0 comments on commit b50ab77

Please sign in to comment.