mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 06:43:34 +01:00
first integration test
This commit is contained in:
parent
70ae102597
commit
2f2330c450
1 changed files with 41 additions and 0 deletions
41
tests/integration/api_activitypub_repository_test.go
Normal file
41
tests/integration/api_activitypub_repository_test.go
Normal file
|
@ -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)
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue