-
Notifications
You must be signed in to change notification settings - Fork 9
/
workspaces_test.go
76 lines (64 loc) · 1.8 KB
/
workspaces_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
package rockset_test
import (
"errors"
"testing"
"github.com/stretchr/testify/suite"
"github.com/rockset/rockset-go-client"
rockerr "github.com/rockset/rockset-go-client/errors"
"github.com/rockset/rockset-go-client/internal/test"
"github.com/rockset/rockset-go-client/option"
)
type SuiteWorkspace struct {
suite.Suite
rc *rockset.RockClient
ws string
}
func TestSuiteWorkspace(t *testing.T) {
rc, randomName := vcrTestClient(t, t.Name())
s := SuiteWorkspace{
rc: rc,
ws: randomName("ws"),
}
suite.Run(t, &s)
}
func (s *SuiteWorkspace) SetupSuite() {
ctx := test.Context()
_, err := s.rc.CreateWorkspace(ctx, s.ws,
option.WithWorkspaceDescription(test.Description()))
s.Require().NoError(err)
err = s.rc.Wait.UntilWorkspaceAvailable(ctx, s.ws)
s.Require().NoError(err)
}
func (s *SuiteWorkspace) TearDownSuite() {
ctx := test.Context()
err := s.rc.DeleteWorkspace(ctx, s.ws)
s.Require().NoError(err)
err = s.rc.Wait.UntilWorkspaceGone(ctx, s.ws)
s.Require().NoError(err)
}
func (s *SuiteWorkspace) TestGetWorkspace() {
ctx := test.Context()
ws, err := s.rc.GetWorkspace(ctx, s.ws)
s.Require().NoError(err)
s.Require().Equal(s.ws, ws.GetName())
}
func (s *SuiteWorkspace) TestGetPersistentWorkspace() {
ctx := test.Context()
ws, err := s.rc.GetWorkspace(ctx, test.PersistentWorkspace)
s.Require().NoError(err)
s.Require().Equal(test.PersistentWorkspace, ws.GetName())
}
func (s *SuiteWorkspace) TestGetNonExistingWorkspace() {
ctx := test.Context()
_, err := s.rc.GetWorkspace(ctx, test.RandomString(16))
s.Require().Error(err)
var re rockerr.Error
s.Require().True(errors.As(err, &re))
s.Assert().True(re.IsNotFoundError())
}
func (s *SuiteWorkspace) TestListWorkspace() {
ctx := test.Context()
list, err := s.rc.ListWorkspaces(ctx)
s.Require().NoError(err)
s.Require().NotEmpty(list)
}