From e44321221ec2355edb43442d2f260ae5a32c2610 Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 15 Nov 2023 15:07:23 +0100 Subject: [PATCH] WIP: Add test for parser --- routers/api/v1/activitypub/repository_test.go | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 routers/api/v1/activitypub/repository_test.go diff --git a/routers/api/v1/activitypub/repository_test.go b/routers/api/v1/activitypub/repository_test.go new file mode 100644 index 0000000000..baf5d22096 --- /dev/null +++ b/routers/api/v1/activitypub/repository_test.go @@ -0,0 +1,43 @@ +// 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 + wantErr error + } + + tests := map[string]testPair{ + "empty": { + item: "", + want: ActorData{}, + }, + "withActorID": { + item: "https://repo.prod.meissa.de/api/v1/activitypub/user-id/1", + want: ActorData{ + schema: "https://", + userId: "1", + host: "repo.prod.meissa.de", + port: "", + }, + }, + } + + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + _, err := tt.want.parseActor(tests[name].item) + + if (err != nil || tt.wantErr != nil) && tt.wantErr.Error() != err.Error() { + t.Errorf("parseActor() error = \"%v\", wantErr \"%v\"", err, tt.wantErr) + return + } + }) + } +}