Skip to content

Commit d34eefe

Browse files
committed
convert remaining bssd tests to lssd
1 parent 14607da commit d34eefe

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

internal/namespaces/instance/v1/custom_image_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func Test_ImageUpdate(t *testing.T) {
244244

245245
t.Run("Add extra volume", core.Test(&core.TestConfig{
246246
BeforeFunc: core.BeforeFuncCombine(
247-
createVolume("Volume", 20, instanceSDK.VolumeVolumeTypeBSSD),
247+
createNonEmptyVolume("Volume", 20),
248248
core.ExecStoreBeforeCmd(
249249
"SnapshotVol",
250250
`scw instance snapshot create -w name=snapVol volume-id={{ .Volume.ID }}`,

internal/namespaces/instance/v1/custom_snapshot_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func Test_UpdateSnapshot(t *testing.T) {
1414
t.Run("Change tags", core.Test(&core.TestConfig{
1515
Commands: instance.GetCommands(),
1616
BeforeFunc: core.BeforeFuncCombine(
17-
createVolume("Volume", 10, instanceSDK.VolumeVolumeTypeBSSD),
17+
createNonEmptyVolume("Volume", 10),
1818
core.ExecStoreBeforeCmd(
1919
"CreateSnapshot",
2020
"scw instance snapshot create volume-id={{ .Volume.ID }} name=cli-test-snapshot-update-tags tags.0=foo tags.1=bar",
@@ -42,7 +42,7 @@ func Test_UpdateSnapshot(t *testing.T) {
4242
t.Run("Change name", core.Test(&core.TestConfig{
4343
Commands: instance.GetCommands(),
4444
BeforeFunc: core.BeforeFuncCombine(
45-
createVolume("Volume", 10, instanceSDK.VolumeVolumeTypeBSSD),
45+
createNonEmptyVolume("Volume", 10),
4646
core.ExecStoreBeforeCmd(
4747
"CreateSnapshot",
4848
"scw instance snapshot create volume-id={{ .Volume.ID }} name=cli-test-snapshot-update-name tags.0=foo tags.1=bar",

internal/namespaces/instance/v1/helpers_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ func createVolume(
109109
}
110110
}
111111

112+
func createNonEmptyVolume(metaKey string, sizeInGB int) core.BeforeFunc {
113+
return func(ctx *core.BeforeFuncCtx) error {
114+
cmd := fmt.Sprintf(
115+
"scw instance server create type=DEV1-S root-volume=local:%dGB stopped=true",
116+
sizeInGB,
117+
)
118+
server := ctx.ExecuteCmd(strings.Split(cmd, " "))
119+
createServerResponse := server.(*instance.ServerWithWarningsResponse)
120+
serverID := createServerResponse.Server.ID
121+
volume := createServerResponse.Server.Volumes["0"]
122+
ctx.Meta[metaKey] = volume
123+
124+
cmd = fmt.Sprintf("scw instance server detach-volume volume-id=%s", volume.ID)
125+
_ = ctx.ExecuteCmd(strings.Split(cmd, " "))
126+
127+
cmd = fmt.Sprintf("scw instance server delete %s", serverID)
128+
_ = ctx.ExecuteCmd(strings.Split(cmd, " "))
129+
130+
return nil
131+
}
132+
}
133+
112134
// deleteVolume deletes a volume previously registered in the context Meta at metaKey.
113135
func deleteVolume(metaKey string) core.AfterFunc { //nolint: unparam
114136
return core.ExecAfterCmd("scw instance volume delete {{ ." + metaKey + ".ID }}")

internal/namespaces/instance/v1/instance_cli_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Test_GetServer(t *testing.T) {
4040
func Test_CreateVolume(t *testing.T) {
4141
t.Run("Simple", core.Test(&core.TestConfig{
4242
Commands: instance.GetCommands(),
43-
Cmd: "scw instance volume create name=test volume-type=b_ssd size=20G",
43+
Cmd: "scw instance volume create name=test volume-type=l_ssd size=20G",
4444
Check: core.TestCheckCombine(
4545
core.TestCheckExitCode(0),
4646
func(t *testing.T, ctx *core.CheckFuncCtx) {
@@ -54,7 +54,7 @@ func Test_CreateVolume(t *testing.T) {
5454

5555
t.Run("Bad size unit", core.Test(&core.TestConfig{
5656
Commands: instance.GetCommands(),
57-
Cmd: "scw instance volume create name=test volume-type=b_ssd size=20",
57+
Cmd: "scw instance volume create name=test volume-type=l_ssd size=20",
5858
Check: core.TestCheckCombine(
5959
core.TestCheckGolden(),
6060
core.TestCheckExitCode(1),

0 commit comments

Comments
 (0)