Skip to content

Commit 300e133

Browse files
authored
test(instance): server create with snapshot and no image (#3962)
1 parent 1bc46f4 commit 300e133

File tree

2 files changed

+2280
-0
lines changed

2 files changed

+2280
-0
lines changed

internal/namespaces/instance/v1/custom_server_create_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,27 @@ func Test_CreateServer(t *testing.T) {
143143
),
144144
}))
145145

146+
t.Run("valid single local snapshot without image", core.Test(&core.TestConfig{
147+
Commands: instance.GetCommands(),
148+
BeforeFunc: core.BeforeFuncCombine(
149+
core.ExecStoreBeforeCmd("Server", "scw instance server create image=ubuntu_bionic root-volume=local:20GB stopped=true"),
150+
core.ExecStoreBeforeCmd("Snapshot", `scw instance snapshot create volume-id={{ (index .Server.Volumes "0").ID }}`),
151+
),
152+
Cmd: "scw instance server create image=none root-volume=local:{{ .Snapshot.Snapshot.ID }} stopped=true",
153+
Check: core.TestCheckCombine(
154+
core.TestCheckExitCode(0),
155+
func(t *testing.T, ctx *core.CheckFuncCtx) {
156+
assert.NotNil(t, ctx.Result)
157+
assert.Equal(t, 20*scw.GB, ctx.Result.(*instanceSDK.Server).Volumes["0"].Size)
158+
},
159+
),
160+
AfterFunc: core.AfterFuncCombine(
161+
deleteServer("Server"),
162+
deleteServerAfterFunc(),
163+
deleteSnapshot("Snapshot"),
164+
),
165+
}))
166+
146167
t.Run("valid double local volumes", core.Test(&core.TestConfig{
147168
Commands: instance.GetCommands(),
148169
Cmd: "scw instance server create image=ubuntu_bionic root-volume=local:10GB additional-volumes.0=l:10G stopped=true",

0 commit comments

Comments
 (0)