forked from go-ap/activitypub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers_test.go
146 lines (122 loc) · 3.11 KB
/
helpers_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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package activitypub
import (
"testing"
)
func TestOnObject(t *testing.T) {
ob := ObjectNew(ArticleType)
err := OnObject(ob, func(o *Object) error {
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
err = OnObject(ob, func(o *Object) error {
if o.Type != ob.Type {
t.Errorf("In function type %s different than expected, %s", o.Type, ob.Type)
}
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
}
func TestOnActivity(t *testing.T) {
ob := ObjectNew(ArticleType)
act := ActivityNew("test", CreateType, ob)
err := OnActivity(act, func(a *Activity) error {
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
err = OnActivity(act, func(a *Activity) error {
if a.Type != act.Type {
t.Errorf("In function type %s different than expected, %s", a.Type, act.Type)
}
if a.ID != act.ID {
t.Errorf("In function ID %s different than expected, %s", a.ID, act.ID)
}
if a.Object != act.Object {
t.Errorf("In function object %s different than expected, %s", a.Object, act.Object)
}
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
}
func TestOnIntransitiveActivity(t *testing.T) {
act := IntransitiveActivityNew("test", ArriveType)
err := OnIntransitiveActivity(act, func(a *IntransitiveActivity) error {
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
err = OnIntransitiveActivity(act, func(a *IntransitiveActivity) error {
if a.Type != act.Type {
t.Errorf("In function type %s different than expected, %s", a.Type, act.Type)
}
if a.ID != act.ID {
t.Errorf("In function ID %s different than expected, %s", a.ID, act.ID)
}
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
}
func TestOnQuestion(t *testing.T) {
act := QuestionNew("test")
err := OnQuestion(act, func(a *Question) error {
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
err = OnQuestion(act, func(a *Question) error {
if a.Type != act.Type {
t.Errorf("In function type %s different than expected, %s", a.Type, act.Type)
}
if a.ID != act.ID {
t.Errorf("In function ID %s different than expected, %s", a.ID, act.ID)
}
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
}
func TestOnPerson(t *testing.T) {
pers := PersonNew("testPerson")
err := OnActor(pers, func(a *Person) error {
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
err = OnActor(pers, func(p *Person) error {
if p.Type != pers.Type {
t.Errorf("In function type %s different than expected, %s", p.Type, pers.Type)
}
if p.ID != pers.ID {
t.Errorf("In function ID %s different than expected, %s", p.ID, pers.ID)
}
return nil
})
if err != nil {
t.Errorf("Unexpected error returned %s", err)
}
}
func TestOnCollection(t *testing.T) {
t.Skipf("TODO")
}
func TestOnCollectionPage(t *testing.T) {
t.Skipf("TODO")
}
func TestOnOrderedCollection(t *testing.T) {
t.Skipf("TODO")
}
func TestOnOrderedCollectionPage(t *testing.T) {
t.Skipf("TODO")
}