Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-29 21:26:10 +01:00
forgejo/models/activitypub/actor_test.go

55 lines
1 KiB
Go
Raw Normal View History

2023-11-15 15:07:23 +01: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 16:03:05 +01:00
item string
want ActorData
2023-11-15 15:07:23 +01:00
}
tests := map[string]testPair{
"empty": {
item: "",
want: ActorData{},
},
2023-11-16 16:03:05 +01:00
"withValidActorID": {
2023-11-15 15:07:23 +01:00
item: "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1",
want: ActorData{
2023-11-16 16:03:05 +01: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 15:07:23 +01:00
userId: "1",
2023-11-16 16:03:05 +01:00
path: "/api/v1/activitypub/user-id/1",
2023-11-15 15:07:23 +01:00
host: "repo.prod.meissa.de",
port: "",
},
},
}
2023-11-16 16:03:05 +01:00
for name, _ := range tests {
2023-11-15 15:07:23 +01:00
t.Run(name, func(t *testing.T) {
2023-11-16 16:04:50 +01:00
_, err := ParseActorData(tests[name].item)
2023-11-15 15:07:23 +01:00
2023-11-16 16:03:05 +01:00
if err != nil {
t.Errorf("parseActor() error = \"%v\"", err)
2023-11-15 15:07:23 +01:00
return
}
2023-11-16 16:03:05 +01:00
2023-11-15 15:07:23 +01:00
})
}
}