-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi_key_test.go
72 lines (54 loc) · 1.64 KB
/
api_key_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
//go:build integration
package cmd_test
import (
"fmt"
"testing"
"github.com/rockset/rockset-go-client"
"github.com/rockset/rockset-go-client/option"
"github.com/stretchr/testify/suite"
"github.com/rockset/cli/cmd"
"github.com/rockset/cli/internal/test"
)
type APIKeySuite struct {
suite.Suite
rc *rockset.RockClient
name string
}
func TestAPIKeySuite(t *testing.T) {
test.SkipUnlessIntegrationTest(t)
s := APIKeySuite{
name: "random",
}
suite.Run(t, &s)
}
func (s *APIKeySuite) TearDownSuite() {
// try to remove the apikey in case it is lingering
c := cmd.NewRootCmd("test")
_ = test.Wrapper(s.T(), c, "delete", "apikey", s.name)
_ = c.Execute()
}
func (s *APIKeySuite) Test_0_Create() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "create", "apikey", s.name)
s.Equal(fmt.Sprintf("apikey %s created\n", s.name), out.String())
}
func (s *APIKeySuite) Test_1_Get() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "get", "apikey", s.name)
s.NotEmpty(out.String())
}
func (s *APIKeySuite) Test_2_List() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "list", "apikey")
s.NotEmpty(out.String())
}
func (s *APIKeySuite) Test_3_Update() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "update", "apikey", s.name, "--state", string(option.KeySuspended))
s.Equal(fmt.Sprintf("apikey %s updated to %s\n", s.name, option.KeySuspended), out.String())
}
func (s *APIKeySuite) Test_8_Delete() {
c := cmd.NewRootCmd("test")
out := test.WrapAndExecute(s.T(), c, "delete", "apikey", s.name)
s.Equal(fmt.Sprintf("apikey %s deleted\n", s.name), out.String())
}