11 func TestDecode(t *testing.T) {
12 f, err := os.Open("testdata/announce1.json")
19 t.Fatal("decode activity", err)
21 want := "https://lemmy.sdf.org/activities/like/b5bd1577-9677-4130-8312-cd2e2fd4ea44"
22 inner, err := a.Unwrap(nil)
24 t.Fatal("unwrap activity:", err)
27 t.Errorf("wanted wrapped activity id %s, got %s", want, inner.ID)
31 func TestTag(t *testing.T) {
36 {"testdata/note/akkoma.json", "@otl@apubtest2.srcbeat.com"},
37 {"testdata/note/lemmy.json", "@Feathercrown@lemmy.world"},
38 {"testdata/note/mastodon.json", "@selfhosted@lemmy.world"},
40 for _, tt := range tests {
41 f, err := os.Open(tt.Name)
49 t.Errorf("%s: decode: %v", tt.Name, err)
53 t.Errorf("%s: no tags", tt.Name)
57 for _, tag := range a.Tag {
58 if tag.Name == tt.Mention {
63 t.Errorf("%s: did not find mention %s", tt.Name, tt.Mention)
68 func TestInboxes(t *testing.T) {
70 "https://apubtest2.srcbeat.com/otl/inbox",
71 "https://hachyderm.io/inbox",
72 "https://lemmy.world/inbox",
73 "https://social.harpia.red/inbox",
76 root := "testdata/actor"
77 dirent, err := os.ReadDir("testdata/actor")
81 actors := make([]Actor, len(dirent))
82 for i, ent := range dirent {
83 f, err := os.Open(path.Join(root, ent.Name()))
88 a, err := DecodeActor(f)
94 got := Inboxes(actors)
96 if !reflect.DeepEqual(want, got) {
97 t.Errorf("unexpected inbox slice of multiple actors, want %s got %s", want, got)