Skip to content

Commit 0eb6229

Browse files
authored
tests(instance): update old tests and remove unsupported ones (scaleway#4220)
1 parent a5b4e5d commit 0eb6229

7 files changed

+2212
-5564
lines changed

internal/namespaces/instance/v1/custom_server_action_test.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -141,35 +141,3 @@ func Test_ServerAction(t *testing.T) {
141141
),
142142
}))
143143
}
144-
145-
func Test_ServerEnableRoutedIP(t *testing.T) {
146-
t.Run("simple", core.Test(&core.TestConfig{
147-
Commands: instance.GetCommands(),
148-
BeforeFunc: core.ExecStoreBeforeCmd("Server", "scw instance server create zone=fr-par-3 type=PRO2-XXS image=ubuntu_jammy routed-ip-enabled=false ip=new --wait"),
149-
Cmd: `scw instance server enable-routed-ip zone=fr-par-3 {{ .Server.ID }} --wait`,
150-
Check: core.TestCheckCombine(
151-
func(t *testing.T, ctx *core.CheckFuncCtx) {
152-
t.Helper()
153-
storedServer := ctx.Meta["Server"].(*instanceSDK.Server)
154-
api := instanceSDK.NewAPI(ctx.Client)
155-
server, err := api.GetServer(&instanceSDK.GetServerRequest{
156-
Zone: storedServer.Zone,
157-
ServerID: storedServer.ID,
158-
})
159-
assert.Nil(t, err)
160-
assert.Equal(t, scw.BoolPtr(true), server.Server.RoutedIPEnabled) //nolint: staticcheck // Field is deprecated but tested
161-
ip, err := api.GetIP(&instanceSDK.GetIPRequest{
162-
Zone: storedServer.Zone,
163-
IP: storedServer.PublicIP.ID,
164-
})
165-
assert.Nil(t, err)
166-
assert.Equal(t, instanceSDK.IPTypeRoutedIPv4, ip.IP.Type)
167-
},
168-
core.TestCheckGolden(),
169-
core.TestCheckExitCode(0),
170-
),
171-
AfterFunc: core.AfterFuncCombine(
172-
core.ExecAfterCmd("scw instance server delete zone=fr-par-3 {{ .Server.ID }} force-shutdown=true with-ip=true with-volumes=local"),
173-
),
174-
}))
175-
}

internal/namespaces/instance/v1/custom_server_create_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
blockSDK "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1"
1212
instanceSDK "github.com/scaleway/scaleway-sdk-go/api/instance/v1"
1313
"github.com/scaleway/scaleway-sdk-go/scw"
14+
"github.com/stretchr/testify/require"
1415
)
1516

1617
// deleteServerAfterFunc deletes the created server and its attached volumes and IPs.
@@ -390,13 +391,14 @@ func Test_CreateServer(t *testing.T) {
390391

391392
t.Run("with ipv6", core.Test(&core.TestConfig{
392393
Commands: instance.GetCommands(),
393-
Cmd: "scw instance server create image=ubuntu_bionic routed-ip-enabled=false ipv6=true -w", // IPv6 is created at runtime
394+
Cmd: "scw instance server create image=ubuntu_bionic ip=ipv6 dynamic-ip-required=false -w", // IPv6 is created at runtime
394395
Check: core.TestCheckCombine(
395396
func(t *testing.T, ctx *core.CheckFuncCtx) {
396397
t.Helper()
397-
assert.NotNil(t, ctx.Result)
398-
assert.NotNil(t, ctx.Result.(*instanceSDK.Server).IPv6)
399-
assert.NotEmpty(t, ctx.Result.(*instanceSDK.Server).IPv6.Address)
398+
require.NotNil(t, ctx.Result, "Server is nil")
399+
server := ctx.Result.(*instanceSDK.Server)
400+
assert.Len(t, server.PublicIPs, 1)
401+
assert.Equal(t, instanceSDK.ServerIPIPFamilyInet6, server.PublicIPs[0].Family)
400402
},
401403
core.TestCheckExitCode(0),
402404
),

internal/namespaces/instance/v1/instance_cli_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,21 @@ func Test_GetServer(t *testing.T) {
3939
func Test_CreateVolume(t *testing.T) {
4040
t.Run("Simple", core.Test(&core.TestConfig{
4141
Commands: instance.GetCommands(),
42-
Cmd: "scw instance volume create name=test size=20G",
42+
Cmd: "scw instance volume create name=test volume-type=b_ssd size=20G",
4343
Check: core.TestCheckCombine(
44+
core.TestCheckExitCode(0),
4445
func(t *testing.T, ctx *core.CheckFuncCtx) {
4546
t.Helper()
47+
require.NotNil(t, ctx.Result)
4648
assert.Equal(t, "test", ctx.Result.(*instanceSDK.CreateVolumeResponse).Volume.Name)
4749
},
48-
core.TestCheckExitCode(0),
4950
),
5051
AfterFunc: core.ExecAfterCmd("scw instance volume delete {{ .CmdResult.Volume.ID }}"),
5152
}))
5253

5354
t.Run("Bad size unit", core.Test(&core.TestConfig{
5455
Commands: instance.GetCommands(),
55-
Cmd: "scw instance volume create name=test size=20",
56+
Cmd: "scw instance volume create name=test volume-type=b_ssd size=20",
5657
Check: core.TestCheckCombine(
5758
core.TestCheckGolden(),
5859
core.TestCheckExitCode(1),

0 commit comments

Comments
 (0)