Files
lotherk 1b490485ff refactor: import Gotea from Gitea v28.4.0
Rename the main module to gotea.dev and the binary to gotea, and update the application name and English locale. Keep the external gitea.dev/sdk and gitea.dev/actionslib module imports unchanged.

Assisted-by: OpenCode:DeepSeek-V4.1-Flash
2026-11-22 12:13:09 +00:00

60 lines
1.3 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
import (
"testing"
"gotea.dev/modules/json"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPullRequestPayloadSynchronizeBeforeAfter(t *testing.T) {
payload := &PullRequestPayload{
Action: HookIssueSynchronized,
Before: "1111111111111111111111111111111111111111",
After: "2222222222222222222222222222222222222222",
Index: 12,
}
data, err := json.Marshal(payload)
require.NoError(t, err)
assert.JSONEq(t, `{
"action": "synchronized",
"before": "1111111111111111111111111111111111111111",
"after": "2222222222222222222222222222222222222222",
"number": 12,
"commit_id": "",
"pull_request": null,
"repository": null,
"requested_reviewer": null,
"review": null,
"sender": null
}`, string(data))
}
func TestPullRequestPayloadNonSynchronizeOmitsBeforeAfter(t *testing.T) {
payload := &PullRequestPayload{
Action: HookIssueOpened,
Index: 12,
}
data, err := json.Marshal(payload)
require.NoError(t, err)
assert.JSONEq(t, `{
"action": "opened",
"number": 12,
"commit_id": "",
"pull_request": null,
"repository": null,
"requested_reviewer": null,
"review": null,
"sender": null
}`, string(data))
}