mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 09:54:24 +01:00
fix linting
This commit is contained in:
parent
ded7b60d0c
commit
42837f5dab
|
@ -16,9 +16,8 @@ type Sut struct {
|
||||||
func (sut Sut) Validate() []string {
|
func (sut Sut) Validate() []string {
|
||||||
if sut.valid {
|
if sut.valid {
|
||||||
return []string{}
|
return []string{}
|
||||||
} else {
|
|
||||||
return []string{"invalid"}
|
|
||||||
}
|
}
|
||||||
|
return []string{"invalid"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_IsValid(t *testing.T) {
|
func Test_IsValid(t *testing.T) {
|
||||||
|
|
|
@ -11,9 +11,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
forgefed_model "code.gitea.io/gitea/models/forgefed"
|
|
||||||
"code.gitea.io/gitea/models/user"
|
"code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/activitypub"
|
"code.gitea.io/gitea/modules/activitypub"
|
||||||
|
forgefed_modules "code.gitea.io/gitea/modules/forgefed"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/routers"
|
"code.gitea.io/gitea/routers"
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func TestActivityPubRepository(t *testing.T) {
|
||||||
body := resp.Body.Bytes()
|
body := resp.Body.Bytes()
|
||||||
assert.Contains(t, string(body), "@context")
|
assert.Contains(t, string(body), "@context")
|
||||||
|
|
||||||
var repository forgefed_model.Repository
|
var repository forgefed_modules.Repository
|
||||||
err := repository.UnmarshalJSON(body)
|
err := repository.UnmarshalJSON(body)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
@ -81,12 +81,12 @@ func TestActivityPubRepositoryInboxValid(t *testing.T) {
|
||||||
repositoryID := 2
|
repositoryID := 2
|
||||||
c, err := activitypub.NewClient(db.DefaultContext, actionsUser, "not used")
|
c, err := activitypub.NewClient(db.DefaultContext, actionsUser, "not used")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
repoInboxUrl := fmt.Sprintf("%s/api/v1/activitypub/repository-id/%v/inbox",
|
repoInboxURL := fmt.Sprintf("%s/api/v1/activitypub/repository-id/%v/inbox",
|
||||||
srv.URL, repositoryID)
|
srv.URL, repositoryID)
|
||||||
|
|
||||||
activity := []byte(fmt.Sprintf(`{"type":"Like","startTime":"2024-03-27T00:00:00Z","actor":"%s/api/v1/activitypub/user-id/2","object":"%s/api/v1/activitypub/repository-id/%v"}`,
|
activity := []byte(fmt.Sprintf(`{"type":"Like","startTime":"2024-03-27T00:00:00Z","actor":"%s/api/v1/activitypub/user-id/2","object":"%s/api/v1/activitypub/repository-id/%v"}`,
|
||||||
srv.URL, srv.URL, repositoryID))
|
srv.URL, srv.URL, repositoryID))
|
||||||
resp, err := c.Post(activity, repoInboxUrl)
|
resp, err := c.Post(activity, repoInboxURL)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, http.StatusNoContent, resp.StatusCode)
|
assert.Equal(t, http.StatusNoContent, resp.StatusCode)
|
||||||
})
|
})
|
||||||
|
@ -114,11 +114,11 @@ func TestActivityPubRepositoryInboxInvalid(t *testing.T) {
|
||||||
repositoryID := 2
|
repositoryID := 2
|
||||||
c, err := activitypub.NewClient(db.DefaultContext, actionsUser, "not used")
|
c, err := activitypub.NewClient(db.DefaultContext, actionsUser, "not used")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
repoInboxUrl := fmt.Sprintf("%s/api/v1/activitypub/repository-id/%v/inbox",
|
repoInboxURL := fmt.Sprintf("%s/api/v1/activitypub/repository-id/%v/inbox",
|
||||||
srv.URL, repositoryID)
|
srv.URL, repositoryID)
|
||||||
|
|
||||||
activity := []byte(fmt.Sprintf(`{"type":"Wrong"}`))
|
activity := []byte(`{"type":"Wrong"}`)
|
||||||
resp, err := c.Post(activity, repoInboxUrl)
|
resp, err := c.Post(activity, repoInboxURL)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, http.StatusNotAcceptable, resp.StatusCode)
|
assert.Equal(t, http.StatusNotAcceptable, resp.StatusCode)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue