-
Notifications
You must be signed in to change notification settings - Fork 0
/
ganggo-diaspora.tx-rx.bats
129 lines (111 loc) · 2.93 KB
/
ganggo-diaspora.tx-rx.bats
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# vim:ft=sh
#
# All API calls are documented here: https://ganggo.github.io/api/
#
load test_helper
load ganggo_helper
endpoint="http://localhost:9000"
@test "$btf create database" {
psql -U postgres -c "create database g1;"
[ "$?" -eq 0 ]
}
@test "$btf start ganggo#1 server" {
ganggo_start_server g1 "9000"
}
@test "$btf start diaspora#1 server" {
start_app "d1" "3000" "testing_diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs d1" "Starting Diaspora in production")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# unicorn timeout
sleep 15
}
@test "$btf create user" {
ganggo_create_user g1 $endpoint
}
@test "$btf create diaspora user" {
skip "exists already"
}
@test "$btf fetch user token" {
ganggo_fetch_token g1 $endpoint
}
@test "$btf setup user relations" {
ganggo_start_sharing "d1@localhost:3000" $endpoint
}
function send_type() {
type=$1
aspectID=0
[ "$type" == "private" ] && aspectID=1
# create post via ganggo
post "post=helloworld&aspectID=$aspectID" "$endpoint/api/v0/posts"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
postID=$(json_value "ID")
echo "body = $HTTP_BODY"
echo "postID = $postID"
[ "$postID" -gt 0 ]
guid=$(json_value "Guid")
echo "guid = $guid"
[ "$guid" != "null" ]
# check post in diaspora
function cmd() {
public="true"
[ "$type" == "private" ] && public="false"
query "d1" "select count(*) from posts
where guid = '$guid' and public = $public;"
}
code=$(wait_for cmd "1" 120)
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# create comment
post "comment=hellod1" "$endpoint/api/v0/posts/$postID/comments"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
guid=$(json_value "Guid")
echo "body = $HTTP_BODY"
echo "guid = $guid"
[ "$guid" != "null" ]
# check comment
function cmd() {
query "d1" "select count(*) from comments
where guid = '$guid';"
}
code=$(wait_for cmd "1" 120)
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# create like
post "" "$endpoint/api/v0/posts/$postID/likes/true"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
guid=$(json_value "Guid")
echo "body = $HTTP_BODY"
echo "guid = $guid"
[ "$guid" != "null" ]
# check like
function cmd() {
query "d1" "select count(*) from likes
where guid = '$guid';"
}
code=$(wait_for cmd "1" 120)
echo "expected 0, got $code"
[ "$code" -eq "0" ]
}
@test "$btf create public entities and check federation" {
send_type public
}
@test "$btf create private entities and check federation" {
send_type private
}
@test "$btf stop and delete containers" {
stop_app "g1 d1"
[ "$?" -eq 0 ]
remove_app "g1 d1"
[ "$?" -eq 0 ]
}
@test "$btf drop databases" {
psql -U postgres -c "drop database g1;"
[ "$?" -eq 0 ]
psql -U postgres -c "drop database d1;"
[ "$?" -eq 0 ]
}