-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathsdk_errors_test.go
91 lines (81 loc) · 2.64 KB
/
sdk_errors_test.go
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package e2e_test
import (
"testing"
"github.com/scaleway/scaleway-cli/v2/core"
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/test/v1"
sdktest "github.com/scaleway/scaleway-sdk-go/api/test/v1"
"github.com/stretchr/testify/assert"
)
// TestSdkStandardErrors tests standard errors
//
// Some errors ar not tested on purpose:
// - InvalidField: this error is deprecated
// - PermissionsDenied: this error cannot be triggered using the SDK
func TestSdkStandardErrors(t *testing.T) {
t.Skip("Test API not available")
t.Run("invalid-arguments", core.Test(&core.TestConfig{
Commands: test.GetCommands(),
UseE2EClient: true,
DisableParallel: true, // because e2e client is used
Cmd: "scw test human create altitude-in-meter=-7000000",
Check: core.TestCheckCombine(
core.TestCheckExitCode(1),
core.TestCheckGolden(),
),
}))
t.Run("quotas-exceeded", core.Test(&core.TestConfig{
Commands: test.GetCommands(),
UseE2EClient: true,
DisableParallel: true, // because e2e client is used
BeforeFunc: func(ctx *core.BeforeFuncCtx) error {
for range 10 {
ctx.ExecuteCmd([]string{"scw", "test", "human", "create"})
}
return nil
},
Cmd: "scw test human create",
Check: core.TestCheckCombine(
core.TestCheckExitCode(1),
core.TestCheckGolden(),
),
}))
t.Run("transient-state", core.Test(&core.TestConfig{
Commands: test.GetCommands(),
UseE2EClient: true,
DisableParallel: true, // because e2e client is used
BeforeFunc: func(ctx *core.BeforeFuncCtx) error {
ctx.ExecuteCmd([]string{"scw", "test", "human", "create"})
api := sdktest.NewAPI(ctx.Client)
_, err := api.RunHuman(&sdktest.RunHumanRequest{
HumanID: "0194fdc2-fa2f-fcc0-41d3-ff12045b73c8",
})
assert.NoError(t, err)
return nil
},
Cmd: "scw test human update human-id=0194fdc2-fa2f-fcc0-41d3-ff12045b73c8 eyes-color=red",
Check: core.TestCheckCombine(
core.TestCheckExitCode(1),
core.TestCheckGolden(),
),
}))
t.Run("resource-not-found", core.Test(&core.TestConfig{
Commands: test.GetCommands(),
UseE2EClient: true,
DisableParallel: true, // because e2e client is used
Cmd: "scw test human get human-id=0194fdc2-fa2f-fcc0-41d3-ff12045b73c8",
Check: core.TestCheckCombine(
core.TestCheckExitCode(1),
core.TestCheckGolden(),
),
}))
t.Run("out-of-stock", core.Test(&core.TestConfig{
Commands: test.GetCommands(),
UseE2EClient: true,
DisableParallel: true, // because e2e client is used
Cmd: "scw test human create shoe-size=60",
Check: core.TestCheckCombine(
core.TestCheckExitCode(1),
core.TestCheckGolden(),
),
}))
}