-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathcustom_snapshot_test.go
More file actions
72 lines (69 loc) · 2.41 KB
/
custom_snapshot_test.go
File metadata and controls
72 lines (69 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package instance_test
import (
"testing"
"github.com/scaleway/scaleway-cli/v2/core"
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/instance/v1"
instanceSDK "github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"github.com/stretchr/testify/assert"
)
func Test_UpdateSnapshot(t *testing.T) {
t.Skip("Skipping 'UpdateSnapshot' test temporarily")
t.Run("Simple", func(t *testing.T) {
t.Run("Change tags", core.Test(&core.TestConfig{
Commands: instance.GetCommands(),
BeforeFunc: core.BeforeFuncCombine(
createNonEmptyLocalVolume("Volume", 10),
core.ExecStoreBeforeCmd(
"CreateSnapshot",
"scw instance snapshot create volume-id={{ .Volume.ID }} name=cli-test-snapshot-update-tags tags.0=foo tags.1=bar",
),
),
Cmd: "scw instance snapshot update -w {{ .CreateSnapshot.Snapshot.ID }} tags.0=bar tags.1=foo",
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(0),
func(t *testing.T, ctx *core.CheckFuncCtx) {
t.Helper()
assert.NotNil(t, ctx.Result)
snapshot := ctx.Result.(*instanceSDK.Snapshot)
assert.Equal(t, "cli-test-snapshot-update-tags", snapshot.Name)
assert.Len(t, snapshot.Tags, 2)
assert.Equal(t, "bar", snapshot.Tags[0])
assert.Equal(t, "foo", snapshot.Tags[1])
},
),
AfterFunc: core.AfterFuncCombine(
deleteSnapshot("CreateSnapshot"),
deleteVolume(),
),
}))
t.Run("Change name", core.Test(&core.TestConfig{
Commands: instance.GetCommands(),
BeforeFunc: core.BeforeFuncCombine(
createNonEmptyLocalVolume("Volume", 10),
core.ExecStoreBeforeCmd(
"CreateSnapshot",
"scw instance snapshot create volume-id={{ .Volume.ID }} name=cli-test-snapshot-update-name tags.0=foo tags.1=bar",
),
),
Cmd: "scw instance snapshot update -w {{ .CreateSnapshot.Snapshot.ID }} name=cli-test-snapshot-update-name-updated",
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(0),
func(t *testing.T, ctx *core.CheckFuncCtx) {
t.Helper()
assert.NotNil(t, ctx.Result)
snapshot := ctx.Result.(*instanceSDK.Snapshot)
assert.Equal(t, "cli-test-snapshot-update-name-updated", snapshot.Name)
assert.Len(t, snapshot.Tags, 2)
assert.Equal(t, "foo", snapshot.Tags[0])
assert.Equal(t, "bar", snapshot.Tags[1])
},
),
AfterFunc: core.AfterFuncCombine(
deleteSnapshot("CreateSnapshot"),
deleteVolume(),
),
}))
})
}