-
Notifications
You must be signed in to change notification settings - Fork 9
/
aliases_test.go
81 lines (61 loc) · 1.94 KB
/
aliases_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
package rockset_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/rockset/rockset-go-client/internal/test"
"github.com/rockset/rockset-go-client/option"
)
func TestAliases_getAlias(t *testing.T) {
t.Parallel()
ctx := test.Context()
rc, _ := vcrTestClient(t, t.Name())
alias, err := rc.GetAlias(ctx, test.PersistentWorkspace, test.PersistentAlias)
require.NoError(t, err)
assert.Equal(t, "[email protected]", alias.GetCreatorEmail())
}
func TestAliases_listAliases(t *testing.T) {
t.Parallel()
ctx := test.Context()
rc, _ := vcrTestClient(t, t.Name())
aliases, err := rc.ListAliases(ctx)
require.NoError(t, err)
for _, a := range aliases {
t.Logf("workspace: %s", a.GetName())
}
}
func TestAliases_listAliasesForWorkspace(t *testing.T) {
t.Parallel()
ctx := test.Context()
rc, _ := vcrTestClient(t, t.Name())
aliases, err := rc.ListAliases(ctx, option.WithAliasWorkspace(test.PersistentWorkspace))
require.NoError(t, err)
for _, a := range aliases {
t.Logf("workspace: %s", a.GetName())
}
}
func TestAliases_CRUD(t *testing.T) {
t.Parallel()
ctx := test.Context()
rc, randomName := vcrTestClient(t, t.Name())
alias := randomName("alias")
var deleted bool
_, err := rc.CreateAlias(ctx, test.PersistentWorkspace, alias, []string{"commons._events"},
option.WithAliasDescription("original"))
require.NoError(t, err)
t.Cleanup(func() {
if !deleted {
_ = rc.DeleteAlias(ctx, test.PersistentWorkspace, alias)
}
})
err = rc.Wait.UntilAliasAvailable(ctx, test.PersistentWorkspace, alias)
require.NoError(t, err)
err = rc.UpdateAlias(ctx, test.PersistentWorkspace, alias, []string{"commons._events"},
option.WithAliasDescription("updated"))
require.NoError(t, err)
err = rc.Wait.UntilAliasAvailable(ctx, test.PersistentWorkspace, alias)
require.NoError(t, err)
err = rc.DeleteAlias(ctx, test.PersistentWorkspace, alias)
require.NoError(t, err)
deleted = true
}