diff --git a/internal/services/applesilicon/server_test.go b/internal/services/applesilicon/server_test.go index 70fe57129..898b6c01b 100644 --- a/internal/services/applesilicon/server_test.go +++ b/internal/services/applesilicon/server_test.go @@ -13,7 +13,6 @@ import ( ) func TestAccServer_Basic(t *testing.T) { - t.Skip("Skipping AppleSilicon test as this kind of server can't be deleted before 24h") tt := acctest.NewTestTools(t) defer tt.Cleanup() resource.ParallelTest(t, resource.TestCase{ @@ -25,7 +24,7 @@ func TestAccServer_Basic(t *testing.T) { Config: ` resource scaleway_apple_silicon_server main { name = "test-m1" - type = "M1-M" + type = "M2-M" } `, Check: resource.ComposeTestCheckFunc( @@ -43,6 +42,59 @@ func TestAccServer_Basic(t *testing.T) { }) } +func TestAccServer_EnableVPC(t *testing.T) { + t.Skip("Skipping AppleSilicon VPC not available") + tt := acctest.NewTestTools(t) + defer tt.Cleanup() + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ProviderFactories: tt.ProviderFactories, + CheckDestroy: isServerDestroyed(tt), + Steps: []resource.TestStep{ + { + Config: ` + resource scaleway_apple_silicon_server main { + name = "test-m1" + type = "M2-M" + enable_vpc = true + } + `, + Check: resource.ComposeTestCheckFunc( + isServerPresent(tt, "scaleway_apple_silicon_server.main"), + resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "name", "test-m1"), + resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", "M1-M"), + // Computed + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "ip"), + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "vnc_url"), + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "created_at"), + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "deletable_at"), + resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "vpc_status", "vpc_enabled"), + ), + }, + { + Config: ` + resource scaleway_apple_silicon_server main { + name = "test-m1" + type = "M2-M" + enable_vpc = false + } + `, + Check: resource.ComposeTestCheckFunc( + isServerPresent(tt, "scaleway_apple_silicon_server.main"), + resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "name", "test-m1"), + resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", "M1-M"), + // Computed + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "ip"), + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "vnc_url"), + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "created_at"), + resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "deletable_at"), + resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "vpc_status", "vpc_disabled"), + ), + }, + }, + }) +} + func isServerPresent(tt *acctest.TestTools, n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n]