forked from kevadesu/forgejo
Move test to model/activitypub
This commit is contained in:
parent
7193c0bd9b
commit
5729cee3e5
1 changed files with 1 additions and 11 deletions
54
models/activitypub/actor_test.go
Normal file
54
models/activitypub/actor_test.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
// 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 {
|
||||
item string
|
||||
want ActorData
|
||||
}
|
||||
|
||||
tests := map[string]testPair{
|
||||
"empty": {
|
||||
item: "",
|
||||
want: ActorData{},
|
||||
},
|
||||
"withValidActorID": {
|
||||
item: "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1",
|
||||
want: ActorData{
|
||||
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",
|
||||
userId: "1",
|
||||
path: "/api/v1/activitypub/user-id/1",
|
||||
host: "repo.prod.meissa.de",
|
||||
port: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, _ := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
_, err := ParseActorData(tests[name].item)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("parseActor() error = \"%v\"", err)
|
||||
return
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue