8
8
block "github.com/scaleway/scaleway-cli/v2/internal/namespaces/block/v1alpha1"
9
9
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/instance/v1"
10
10
"github.com/scaleway/scaleway-cli/v2/internal/testhelpers"
11
+ blockSDK "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1"
11
12
instanceSDK "github.com/scaleway/scaleway-sdk-go/api/instance/v1"
12
13
"github.com/scaleway/scaleway-sdk-go/scw"
13
14
"github.com/stretchr/testify/assert"
@@ -25,7 +26,7 @@ func Test_ServerTerminate(t *testing.T) {
25
26
"Server" ,
26
27
testServerCommand ("image=ubuntu-jammy ip=new -w" ),
27
28
),
28
- Cmd : `scw instance server terminate {{ .Server.ID }}` ,
29
+ Cmd : `scw instance server terminate {{ .Server.ID }} with-block=true ` ,
29
30
Check : core .TestCheckCombine (
30
31
core .TestCheckGolden (),
31
32
core .TestCheckExitCode (0 ),
@@ -56,7 +57,7 @@ func Test_ServerTerminate(t *testing.T) {
56
57
"Server" ,
57
58
testServerCommand ("image=ubuntu-jammy ip=new -w" ),
58
59
),
59
- Cmd : `scw instance server terminate {{ .Server.ID }} with-ip=true` ,
60
+ Cmd : `scw instance server terminate {{ .Server.ID }} with-ip=true with-block=true ` ,
60
61
Check : core .TestCheckCombine (
61
62
core .TestCheckGolden (),
62
63
core .TestCheckExitCode (0 ),
@@ -98,6 +99,10 @@ func Test_ServerTerminate(t *testing.T) {
98
99
`scw block volume wait terminal-status=available {{ (index .Server.Volumes "1").ID }}` ,
99
100
),
100
101
core .ExecAfterCmd (`scw block volume delete {{ (index .Server.Volumes "1").ID }}` ),
102
+ core .ExecAfterCmd (
103
+ `scw block volume wait terminal-status=available {{ (index .Server.Volumes "0").ID }}` ,
104
+ ),
105
+ core .ExecAfterCmd (`scw block volume delete {{ (index .Server.Volumes "0").ID }}` ),
101
106
),
102
107
DisableParallel : true ,
103
108
}))
@@ -114,16 +119,23 @@ func Test_ServerTerminate(t *testing.T) {
114
119
core .TestCheckExitCode (0 ),
115
120
func (t * testing.T , ctx * core.CheckFuncCtx ) {
116
121
t .Helper ()
117
- api := instanceSDK .NewAPI (ctx .Client )
122
+ api := blockSDK .NewAPI (ctx .Client )
118
123
server := testhelpers .MapValue [* instance.ServerWithWarningsResponse ](
119
124
t ,
120
125
ctx .Meta ,
121
126
"Server" ,
122
127
).Server
123
- volume := testhelpers .MapTValue (t , server .Volumes , "0" )
128
+ rootVolume := testhelpers .MapTValue (t , server .Volumes , "0" )
129
+
130
+ _ , err := api .GetVolume (& blockSDK.GetVolumeRequest {
131
+ VolumeID : rootVolume .ID ,
132
+ Zone : server .Zone ,
133
+ })
134
+ require .IsType (t , & scw.ResourceNotFoundError {}, err )
124
135
125
- _ , err := api .GetVolume (& instanceSDK.GetVolumeRequest {
126
- VolumeID : volume .ID ,
136
+ additionalVolume := testhelpers .MapTValue (t , server .Volumes , "1" )
137
+ _ , err = api .GetVolume (& blockSDK.GetVolumeRequest {
138
+ VolumeID : additionalVolume .ID ,
127
139
Zone : server .Zone ,
128
140
})
129
141
require .IsType (t , & scw.ResourceNotFoundError {}, err )
0 commit comments