1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-23 08:47:42 -05:00
forgejo/models/activitypub/actor_test.go

55 lines
1 KiB
Go
Raw Normal View History

2023-11-15 09:07:23 -05:00
// Copyright 2023 The forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package activitypub
import (
"testing"
)
func Test_ActorParser(t *testing.T) {
type testPair struct {
2023-11-16 10:03:05 -05:00
item string
want ActorData
2023-11-15 09:07:23 -05:00
}
tests := map[string]testPair{
"empty": {
item: "",
want: ActorData{},
},
2023-11-16 10:03:05 -05:00
"withValidActorID": {
2023-11-15 09:07:23 -05:00
item: "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1",
want: ActorData{
2023-11-16 10:03:05 -05:00
schema: "https",
userId: "1",
path: "/api/v1/activitypub/user-id/1",
host: "repo.prod.meissa.de",
port: "",
},
},
"withInvalidActorID": {
item: "https://repo.prod.meissa.de/api/activitypub/user-id/1",
want: ActorData{
schema: "https",
2023-11-15 09:07:23 -05:00
userId: "1",
2023-11-16 10:03:05 -05:00
path: "/api/v1/activitypub/user-id/1",
2023-11-15 09:07:23 -05:00
host: "repo.prod.meissa.de",
port: "",
},
},
}
2023-11-16 10:03:05 -05:00
for name, _ := range tests {
2023-11-15 09:07:23 -05:00
t.Run(name, func(t *testing.T) {
2023-11-16 10:04:50 -05:00
_, err := ParseActorData(tests[name].item)
2023-11-15 09:07:23 -05:00
2023-11-16 10:03:05 -05:00
if err != nil {
t.Errorf("parseActor() error = \"%v\"", err)
2023-11-15 09:07:23 -05:00
return
}
2023-11-16 10:03:05 -05:00
2023-11-15 09:07:23 -05:00
})
}
}