Skip to content

Commit

Permalink
test(instance): server create with snapshot and no image (#3962)
Browse files Browse the repository at this point in the history
  • Loading branch information
Codelax authored Jul 8, 2024
1 parent 1bc46f4 commit 300e133
Show file tree
Hide file tree
Showing 2 changed files with 2,280 additions and 0 deletions.
21 changes: 21 additions & 0 deletions internal/namespaces/instance/v1/custom_server_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,27 @@ func Test_CreateServer(t *testing.T) {
),
}))

t.Run("valid single local snapshot without image", core.Test(&core.TestConfig{
Commands: instance.GetCommands(),
BeforeFunc: core.BeforeFuncCombine(
core.ExecStoreBeforeCmd("Server", "scw instance server create image=ubuntu_bionic root-volume=local:20GB stopped=true"),
core.ExecStoreBeforeCmd("Snapshot", `scw instance snapshot create volume-id={{ (index .Server.Volumes "0").ID }}`),
),
Cmd: "scw instance server create image=none root-volume=local:{{ .Snapshot.Snapshot.ID }} stopped=true",
Check: core.TestCheckCombine(
core.TestCheckExitCode(0),
func(t *testing.T, ctx *core.CheckFuncCtx) {
assert.NotNil(t, ctx.Result)
assert.Equal(t, 20*scw.GB, ctx.Result.(*instanceSDK.Server).Volumes["0"].Size)
},
),
AfterFunc: core.AfterFuncCombine(
deleteServer("Server"),
deleteServerAfterFunc(),
deleteSnapshot("Snapshot"),
),
}))

t.Run("valid double local volumes", core.Test(&core.TestConfig{
Commands: instance.GetCommands(),
Cmd: "scw instance server create image=ubuntu_bionic root-volume=local:10GB additional-volumes.0=l:10G stopped=true",
Expand Down
Loading

0 comments on commit 300e133

Please sign in to comment.