-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiaspora-ganggo.tx-rx.bats
123 lines (104 loc) · 2.99 KB
/
diaspora-ganggo.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
# vim:ft=sh
load test_helper
load ganggo_helper
gngg_endpnt="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 ganggo user" {
ganggo_create_user g1 $gngg_endpnt
}
@test "$btf create diaspora user" {
skip "exists already"
}
@test "$btf setup user relations" {
rails_runner "d1" "user = User.find_by(username: 'd1');
person = Person.find_or_fetch_by_identifier('g1@localhost:9000');
Aspect.find_each {|obj| user.share_with(person, obj)};"
[ "$?" -eq 0 ]
}
function send_type() {
type=$1
# should we send it publicly or limited
if [ "$type" == "private" ]; then
postType="public: false, aspect_ids: aspectIds"
else
postType="public: true"
fi
# send post via diaspora
postID=$(rails_runner "d1" "user = User.find_by(username: 'd1');
aspectIds = Aspect.find_each.collect {|obj| obj.id if obj.user_id == 1 }
puts StatusMessageCreationService.new(user).create(
status_message: {text: 'hello world'}, $postType
).id;")
echo "postID = $postID"
[ "$?" -eq 0 ]
[ "$postID" -gt 0 ]
# check if ganggo received it
function cmd() {
query "g1" "select count(*) from posts where public = true;"
}
code=$(wait_for cmd "1" 120)
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# send comment
guid=$(rails_runner "d1" "user = User.find_by(username: 'd1');
puts CommentService.new(user)
.create($postID, 'commenttext').guid;")
echo "guid = $guid"
[ "$?" -eq 0 ]
# XXX how to check guid
#[ "$guid" != "null" ]
# check comment
function cmd() {
query "g1" "select count(*) from comments where guid = '$guid';"
}
code=$(wait_for cmd "1" 120)
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# send like
guid=$(rails_runner "d1" "user = User.find_by(username: 'd1');
puts LikeService.new(user).create($postID).guid;")
echo "guid = $guid"
[ "$?" -eq 0 ]
# XXX how to check guid
#[ "$guid" != "null" ]
# check comment
function cmd() {
query "g1" "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 ]
}