-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcircle_test.go
74 lines (60 loc) · 1.52 KB
/
circle_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
package mixin
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCircle(t *testing.T) {
store := newKeystoreFromEnv(t)
c, err := NewFromKeystore(&store.Keystore)
if err != nil {
t.Error(err)
t.FailNow()
}
ctx := context.Background()
name := RandomPin()
circle, err := c.CreateCircle(ctx, CreateCircleParams{
Name: name,
})
require.NoError(t, err)
assert.Equal(t, circle.Name, name)
t.Run("read circle", func(t *testing.T) {
c, err := c.ReadCircle(ctx, circle.ID)
require.NoError(t, err)
assert.Equal(t, c.Name, circle.Name)
})
t.Run("update circle", func(t *testing.T) {
newName := RandomPin()
c, err := c.UpdateCircle(ctx, UpdateCircleParams{
CircleID: circle.ID,
Name: newName,
})
require.NoError(t, err)
assert.Equal(t, c.Name, newName)
})
t.Run("add user", func(t *testing.T) {
app, err := c.ReadApp(ctx, c.ClientID)
require.NoError(t, err)
item, err := c.ManageCircle(ctx, ManageCircleParams{
CircleID: circle.ID,
Action: CircleActionAdd,
ItemType: CircleItemTypeUsers,
ItemID: app.CreatorID,
})
require.NoError(t, err)
assert.Equal(t, item.UserID, app.CreatorID)
})
t.Run("list items", func(t *testing.T) {
items, err := c.ListCircleItems(ctx, ListCircleItemsParams{
CircleID: circle.ID,
Limit: 10,
})
require.NoError(t, err)
require.Len(t, items, 1)
})
t.Run("delete circle", func(t *testing.T) {
err := c.DeleteCircle(ctx, circle.ID)
require.NoError(t, err)
})
}