forked from hyperworks/go-getstream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed_test.go
81 lines (63 loc) · 2.16 KB
/
feed_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 getstream
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFeed(t *testing.T) {
client := ConnectTestClient("eu-west")
feed := client.Feed("user", "john2")
activity := NewTestActivity()
addedActivity, e := feed.AddActivity(activity)
assert.Nil(t, e)
assert.NotEqual(t, activity, addedActivity, "AddActivity should not modify existing instance.")
assert.NotNil(t, addedActivity)
assert.NotEmpty(t, addedActivity.ID)
activities, e := feed.Activities(nil)
assert.NoError(t, e)
assert.NotEmpty(t, activities)
assert.Len(t, activities, 1) // otherwise we might be getting result from another test run.
assert.Equal(t, addedActivity.ID, activities[0].ID)
e = feed.RemoveActivity(addedActivity.ID)
assert.NoError(t, e)
activities, e = feed.Activities(nil)
assert.NoError(t, e)
assert.Empty(t, activities)
}
func TestFollow(t *testing.T) {
client := ConnectTestClient("eu-west")
john := client.Feed("user", "john3")
timeline := client.Feed("Test", "test3")
activity := NewTestActivity()
addedActivity, e := timeline.AddActivity(activity)
assert.Nil(t, e)
e = john.Follow("Test", "test3")
assert.NoError(t, e)
activities, e := john.Activities(nil)
assert.NoError(t, e)
assert.NotEmpty(t, activities)
assert.Len(t, activities, 1) // otherwise we might be getting result from another test run.
assert.Equal(t, addedActivity.ID, activities[0].ID)
following, e := john.Following(nil)
assert.NoError(t, e)
assert.NotEmpty(t, following)
assert.Len(t, following, 1) // otherwise we might be getting result from another test run.
followers, e := timeline.Followers(nil)
assert.NoError(t, e)
assert.NotEmpty(t, followers)
assert.Len(t, followers, 1) // otherwise we might be getting result from another test run.
e = john.Unfollow("Test", "test3")
assert.NoError(t, e)
activities, e = john.Activities(nil)
assert.NoError(t, e)
assert.Empty(t, activities)
following, e = john.Following(nil)
assert.NoError(t, e)
assert.Empty(t, following)
followers, e = timeline.Followers(nil)
assert.NoError(t, e)
assert.Empty(t, followers)
e = timeline.RemoveActivity(addedActivity.ID)
assert.NoError(t, e)
}
func TestOptions(t *testing.T) {
}