Skip to content

Commit 4f47dc3

Browse files
committed
tests(instance): update cassettes
1 parent bf2505d commit 4f47dc3

9 files changed

+2318
-1689
lines changed

internal/namespaces/instance/v1/custom.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ func GetCommands() *core.Commands {
5252
cmds.MustFind("instance", "server", "list").Override(serverListBuilder)
5353
cmds.MustFind("instance", "server", "update").Override(serverUpdateBuilder)
5454
cmds.MustFind("instance", "server", "get").Override(serverGetBuilder)
55+
cmds.MustFind("instance", "server", "attach-volume").Override(serverAttachVolumeBuilder)
56+
cmds.MustFind("instance", "server", "detach-volume").Override(serverDetachVolumeBuilder)
5557

5658
cmds.Merge(core.NewCommands(
5759
serverBackupCommand(),

internal/namespaces/instance/v1/custom_server.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,35 @@ func volumeIsFromSBS(api *block.API, zone scw.Zone, volumeID string) bool {
389389
return err == nil
390390
}
391391

392+
func serverAttachVolumeBuilder(c *core.Command) *core.Command {
393+
c.Interceptor = func(ctx context.Context, argsI any, runner core.CommandRunner) (any, error) {
394+
request := argsI.(*instance.AttachServerVolumeRequest)
395+
api := instance.NewAPI(core.ExtractClient(ctx))
396+
397+
return api.AttachVolume(&instance.AttachVolumeRequest{
398+
Zone: request.Zone,
399+
VolumeID: request.VolumeID,
400+
ServerID: request.ServerID,
401+
})
402+
}
403+
404+
return c
405+
}
406+
407+
func serverDetachVolumeBuilder(c *core.Command) *core.Command {
408+
c.Interceptor = func(ctx context.Context, argsI any, runner core.CommandRunner) (any, error) {
409+
request := argsI.(*instance.DetachServerVolumeRequest)
410+
api := instance.NewAPI(core.ExtractClient(ctx))
411+
412+
return api.DetachVolume(&instance.DetachVolumeRequest{
413+
Zone: request.Zone,
414+
VolumeID: request.VolumeID,
415+
})
416+
}
417+
418+
return c
419+
}
420+
392421
func serverGetBuilder(c *core.Command) *core.Command {
393422
// This method is here as a proof of concept before we find the correct way to implement it at larger scale
394423
c.ArgSpecs.GetPositionalArg().AutoCompleteFunc = func(ctx context.Context, prefix string, request any) core.AutocompleteSuggestions {

internal/namespaces/instance/v1/custom_server_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ func Test_ServerVolumeUpdate(t *testing.T) {
9999
Check: func(t *testing.T, ctx *core.CheckFuncCtx) {
100100
t.Helper()
101101
require.NoError(t, ctx.Err)
102-
resp := testhelpers.Value[*instanceSDK.DetachServerVolumeResponse](t, ctx.Result)
102+
resp := testhelpers.Value[*instanceSDK.DetachVolumeResponse](t, ctx.Result)
103103
assert.NotZero(t, resp.Server.Volumes["0"])
104104
assert.Nil(t, resp.Server.Volumes["1"])
105105
assert.Len(
106106
t,
107-
ctx.Result.(*instanceSDK.DetachServerVolumeResponse).Server.Volumes,
107+
ctx.Result.(*instanceSDK.DetachVolumeResponse).Server.Volumes,
108108
1,
109109
)
110110
},
@@ -165,6 +165,7 @@ func Test_ServerUpdateCustom(t *testing.T) {
165165
assert.NotNil(t, resp.Server)
166166
assert.NotNil(t, resp.Server.PublicIP)
167167
assert.Equal(t, ip.Address, resp.Server.PublicIP.Address)
168+
168169
},
169170
core.TestCheckExitCode(0),
170171
),

internal/namespaces/instance/v1/testdata/test-server-volume-update-attach-invalid-volume-uuid.cassette.yaml

Lines changed: 1406 additions & 1170 deletions
Large diffs are not rendered by default.

internal/namespaces/instance/v1/testdata/test-server-volume-update-attach-simple-block-volume.cassette.yaml

Lines changed: 206 additions & 160 deletions
Large diffs are not rendered by default.

internal/namespaces/instance/v1/testdata/test-server-volume-update-attach-simple-local-volume.cassette.yaml

Lines changed: 185 additions & 139 deletions
Large diffs are not rendered by default.

internal/namespaces/instance/v1/testdata/test-server-volume-update-detach-invalid-volume-uuid.cassette.yaml

Lines changed: 156 additions & 78 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
🎲🎲🎲 EXIT CODE: 1 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3-
Invalid arguments 'volume_id'
4-
5-
Details:
6-
- 'volume_id' does not respect constraints
7-
8-
Hint:
9-
Volume 11111111-1111-1111-1111-111111111111 is not attached to this server
3+
Cannot find resource 'volume' with ID '11111111-1111-1111-1111-111111111111'
104
🟥🟥🟥 JSON STDERR 🟥🟥🟥
115
{
12-
"message": "invalid arguments 'volume_id'",
6+
"message": "cannot find resource 'volume' with ID '11111111-1111-1111-1111-111111111111'",
137
"error": {
14-
"details": [
15-
{
16-
"argument_name": "volume_id",
17-
"reason": "constraint",
18-
"help_message": "Volume 11111111-1111-1111-1111-111111111111 is not attached to this server"
19-
}
20-
]
21-
},
22-
"details": "- 'volume_id' does not respect constraints",
23-
"hint": "Volume 11111111-1111-1111-1111-111111111111 is not attached to this server"
8+
"resource": "volume",
9+
"resource_id": "11111111-1111-1111-1111-111111111111"
10+
}
2411
}

internal/namespaces/instance/v1/testdata/test-server-volume-update-detach-simple-block-volume.cassette.yaml

Lines changed: 326 additions & 122 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)