From 2f2330c450b8a40086ee0c202e78478ebf864245 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Sun, 28 Apr 2024 13:52:51 +0200 Subject: [PATCH] first integration test --- .../api_activitypub_repository_test.go | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/integration/api_activitypub_repository_test.go diff --git a/tests/integration/api_activitypub_repository_test.go b/tests/integration/api_activitypub_repository_test.go new file mode 100644 index 0000000000..312ff135b8 --- /dev/null +++ b/tests/integration/api_activitypub_repository_test.go @@ -0,0 +1,41 @@ +// Copyright 2024 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package integration + +import ( + "fmt" + "net/http" + "net/url" + "testing" + + forgefed_model "code.gitea.io/gitea/models/forgefed" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/routers" + + "github.com/stretchr/testify/assert" +) + +func TestActivityPubRepository(t *testing.T) { + setting.Federation.Enabled = true + testWebRoutes = routers.NormalRoutes() + defer func() { + setting.Federation.Enabled = false + testWebRoutes = routers.NormalRoutes() + }() + + onGiteaRun(t, func(*testing.T, *url.URL) { + repositoryID := 2 + req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/activitypub/repository-id/%v", repositoryID)) + resp := MakeRequest(t, req, http.StatusOK) + body := resp.Body.Bytes() + assert.Contains(t, string(body), "@context") + + var repository forgefed_model.Repository + err := repository.UnmarshalJSON(body) + assert.NoError(t, err) + + assert.Equal(t, "", repository.Name) + assert.Equal(t, fmt.Sprintf("activitypub/repository-id/%v$", repository.GetID().String()), repository.ID) + }) +}