Skip to content

Commit 57ffa78

Browse files
committed
fix tests
1 parent 4b08bbd commit 57ffa78

File tree

1 file changed

+28
-58
lines changed

1 file changed

+28
-58
lines changed

tests/integration/pull_merge_test.go

Lines changed: 28 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ func TestPullSquashMessage(t *testing.T) {
11881188
user2Session := loginUser(t, user2.Name)
11891189

11901190
defer test.MockVariableValue(&setting.Repository.PullRequest.PopulateSquashCommentWithCommitMessages, true)()
1191-
defer test.MockVariableValue(&setting.Repository.PullRequest.DefaultMergeMessageSize, 512)()
1191+
defer test.MockVariableValue(&setting.Repository.PullRequest.DefaultMergeMessageSize, 80)()
11921192

11931193
repo, err := repo_service.CreateRepository(t.Context(), user2, user2, repo_service.CreateRepoOptions{
11941194
Name: "squash-message-test",
@@ -1201,7 +1201,6 @@ func TestPullSquashMessage(t *testing.T) {
12011201

12021202
type commitInfo struct {
12031203
userName string
1204-
commitSummary string
12051204
commitMessage string
12061205
}
12071206

@@ -1211,105 +1210,76 @@ func TestPullSquashMessage(t *testing.T) {
12111210
expectedMessage string
12121211
}{
12131212
{
1214-
name: "Only summaries",
1213+
name: "Single-line messages",
12151214
commitInfos: []*commitInfo{
12161215
{
12171216
userName: user2.Name,
1218-
commitSummary: "Implement the login endpoint",
1217+
commitMessage: "commit msg 1",
12191218
},
12201219
{
12211220
userName: user2.Name,
1222-
commitSummary: "Validate request body",
1221+
commitMessage: "commit msg 2",
12231222
},
12241223
},
1225-
expectedMessage: `* Implement the login endpoint
1224+
expectedMessage: `* commit msg 1
12261225
1227-
* Validate request body
1226+
* commit msg 2
12281227
12291228
`,
12301229
},
12311230
{
1232-
name: "Summaries and messages",
1231+
name: "Multiple-line messages",
12331232
commitInfos: []*commitInfo{
12341233
{
1235-
userName: user2.Name,
1236-
commitSummary: "Refactor user service",
1237-
commitMessage: `Implement the login endpoint.
1238-
Validate request body.`,
1234+
userName: user2.Name,
1235+
commitMessage: `commit msg 1
1236+
1237+
Commit description.`,
12391238
},
12401239
{
1241-
userName: user2.Name,
1242-
commitSummary: "Add email notification service",
1243-
commitMessage: `Implements a new email notification module.
1240+
userName: user2.Name,
1241+
commitMessage: `commit msg 2
12441242
1245-
- Supports templating
1246-
- Supports HTML and plain text modes
1247-
- Includes retry logic`,
1243+
- Detail 1
1244+
- Detail 2`,
12481245
},
12491246
},
1250-
expectedMessage: `* Refactor user service
1251-
1252-
Implement the login endpoint.
1253-
Validate request body.
1247+
expectedMessage: `* commit msg 1
12541248
1255-
* Add email notification service
1249+
Commit description.
12561250
1257-
Implements a new email notification module.
1251+
* commit msg 2
12581252
1259-
- Supports templating
1260-
- Supports HTML and plain text modes
1261-
- Includes retry logic
1253+
- Detail 1
1254+
- Detail 2
12621255
12631256
`,
12641257
},
12651258
{
1266-
name: "Long Message",
1259+
name: "Too long message",
12671260
commitInfos: []*commitInfo{
12681261
{
12691262
userName: user2.Name,
1270-
commitSummary: "Add advanced validation logic for user onboarding",
1271-
commitMessage: `This commit introduces a comprehensive validation layer for the user onboarding flow.
1272-
The primary goal is to ensure that all input data is strictly validated before being processed by downstream services.
1273-
This improves system reliability and significantly reduces runtime exceptions in the registration pipeline.
1274-
1275-
The validation logic includes:
1276-
1277-
1. Email format checking using RFC 5322-compliant patterns.
1278-
2. Username length and character limitation enforcement.
1279-
3. Password strength enforcement, including:
1280-
- Minimum length checks
1281-
- Mixed character type detection
1282-
- Optional entropy-based scoring
1283-
4. Optional phone number validation using region-specific rules.
1284-
`,
1263+
commitMessage: `loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong message`,
12851264
},
12861265
},
1287-
expectedMessage: `* Add advanced validation logic for user onboarding
1288-
1289-
This commit introduces a comprehensive validation layer for the user onboarding flow.
1290-
The primary goal is to ensure that all input data is strictly validated before being processed by downstream services.
1291-
This improves system reliability and significantly reduces runtime exceptions in the registration pipeline.
1292-
1293-
The validation logic includes:
1294-
1295-
1. Email format checking using RFC 5322-compliant patterns.
1296-
2. Username length and character limitation enforceme...`,
1266+
expectedMessage: `* looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...`,
12971267
},
12981268
{
12991269
name: "Test Co-authored-by",
13001270
commitInfos: []*commitInfo{
13011271
{
13021272
userName: user2.Name,
1303-
commitSummary: "Implement the login endpoint",
1273+
commitMessage: "commit msg 1",
13041274
},
13051275
{
13061276
userName: "user4",
1307-
commitSummary: "Validate request body",
1277+
commitMessage: "commit msg 2",
13081278
},
13091279
},
1310-
expectedMessage: `* Implement the login endpoint
1280+
expectedMessage: `* commit msg 1
13111281
1312-
* Validate request body
1282+
* commit msg 2
13131283
13141284
---------
13151285
@@ -1323,7 +1293,7 @@ Co-authored-by: user4 <[email protected]>
13231293
branchName := "test-branch-" + strconv.Itoa(tcNum)
13241294
for infoIdx, info := range tc.commitInfos {
13251295
createFileOpts := createFileInBranchOptions{
1326-
CommitMessage: info.commitSummary + "\n\n" + info.commitMessage,
1296+
CommitMessage: info.commitMessage,
13271297
CommitterName: info.userName,
13281298
CommitterEmail: util.Iif(info.userName != "", info.userName+"@example.com", ""),
13291299
OldBranch: util.Iif(infoIdx == 0, "main", branchName),

0 commit comments

Comments
 (0)