forked from scaleway/scaleway-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_user_data_test.go
More file actions
51 lines (46 loc) · 1.46 KB
/
custom_user_data_test.go
File metadata and controls
51 lines (46 loc) · 1.46 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
package instance
import (
"testing"
"github.com/scaleway/scaleway-cli/internal/core"
)
func Test_UserDataGet(t *testing.T) {
t.Run("Get an existing key", core.Test(&core.TestConfig{
BeforeFunc: core.BeforeFuncCombine(
createServer("Server"),
core.ExecBeforeCmd("scw instance user-data set {{.Server.ID}} key=happy content=true"),
),
Commands: GetCommands(),
Cmd: "scw instance user-data get {{.Server.ID}} key=happy",
AfterFunc: deleteServer("Server"),
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(0),
),
}))
t.Run("Get an nonexistent key", core.Test(&core.TestConfig{
BeforeFunc: createServer("Server"),
Commands: GetCommands(),
Cmd: "scw instance user-data get {{.Server.ID}} key=happy",
AfterFunc: deleteServer("Server"),
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(1),
),
}))
}
func Test_UserDataList(t *testing.T) {
t.Run("Simple", core.Test(&core.TestConfig{
BeforeFunc: core.BeforeFuncCombine(
createServer("Server"),
core.ExecBeforeCmd("scw instance user-data set {{ .Server.ID }} key=foo content=bar"),
core.ExecBeforeCmd("scw instance user-data set {{ .Server.ID }} key=bar content=foo"),
),
Commands: GetCommands(),
Cmd: "scw instance user-data list server-id={{ .Server.ID }}",
AfterFunc: deleteServer("Server"),
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(0),
),
}))
}