mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-25 09:15:17 +01:00
Consolidate all Go tests. Coverage is identical to before. Go tests are around 5% faster while being 7% smaller. No non-test code is touched.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/modules/json"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPullRequestPayload(t *testing.T) {
|
|
for _, tt := range []struct {
|
|
payload PullRequestPayload
|
|
want string
|
|
}{
|
|
{
|
|
payload: PullRequestPayload{
|
|
Action: HookIssueSynchronized,
|
|
Before: "1111111111111111111111111111111111111111",
|
|
After: "2222222222222222222222222222222222222222",
|
|
Index: 12,
|
|
},
|
|
want: `
|
|
"action": "synchronized",
|
|
"before": "1111111111111111111111111111111111111111",
|
|
"after": "2222222222222222222222222222222222222222",`,
|
|
},
|
|
{
|
|
payload: PullRequestPayload{Action: HookIssueOpened, Index: 12},
|
|
want: `
|
|
"action": "opened",`,
|
|
},
|
|
} {
|
|
t.Run(string(tt.payload.Action), func(t *testing.T) {
|
|
data, err := json.Marshal(&tt.payload)
|
|
require.NoError(t, err)
|
|
assert.JSONEq(t, `{`+tt.want+`
|
|
"number": 12,
|
|
"commit_id": "",
|
|
"pull_request": null,
|
|
"repository": null,
|
|
"requested_reviewer": null,
|
|
"review": null,
|
|
"sender": null
|
|
}`, string(data))
|
|
})
|
|
}
|
|
}
|