-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctional_enriched_feed_test.go
84 lines (77 loc) · 1.81 KB
/
functional_enriched_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
82
83
84
package main
import (
"gopkg.in/gavv/httpexpect.v1"
"net/http"
"testing"
"time"
)
func AssertEnrichedFeedFlow(t *testing.T) {
//given
expect := httpexpect.New(t, testServer.URL)
object := "photo:1"
//when
expect.POST("/scott/feed").
WithJSON(map[string]string{
"actor": "scott",
"verb": "post",
"object": object}).
Expect().
Status(http.StatusOK)
//and
expect.POST("/smith/feed").
WithJSON(map[string]string{
"actor": "smith",
"verb": "share",
"object": object,
"target": "someone"}).
Expect().
Status(http.StatusOK)
//then
expect.POST("/aron/feed").
WithJSON(map[string]string{
"actor": "aron",
"verb": "like",
"object": object,
"target": "someone"}).
Expect().
Status(http.StatusOK)
//and
time.Sleep(asyncCallTimeout)
//expect
expect.GET("/aron/feed").WithQuery("includeRelated", "true").
Expect().
Status(http.StatusOK).
JSON().Object().
Value("my_feed").Array().
Element(0).Object().
NotContainsKey("related")
//then
expect.POST("/aron/action").
WithJSON(map[string]string{
"follow": "scott"}).
Expect().
Status(http.StatusOK)
//and
time.Sleep(asyncCallTimeout)
//expect
obj := expect.GET("/aron/feed").WithQuery("includeRelated", "true").
Expect().
Status(http.StatusOK).
JSON().Object()
obj.Value("next_url").String().NotEmpty()
array := obj.Value("my_feed").Array()
array.Length().Equal(2)
feed := array.Element(0).Object().
ValueEqual("actor", "aron").
ValueEqual("object", object).
ValueEqual("target", "someone").
ValueEqual("verb", "like")
feed.Value("datetime").NotNull()
relatedArray := feed.Value("related").Array()
relatedArray.Length().Equal(1)
relatedArray.Element(0).Object().
ValueEqual("actor", "scott").
ValueEqual("object", object).
ValueEqual("verb", "post").
NotContainsKey("target")
}