forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
* upstream/main: Correctly handle select on multiple channels in Queues (go-gitea#22146) Support template for merge message description (go-gitea#22248)
- Loading branch information
Showing
10 changed files
with
146 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package pull | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_expandDefaultMergeMessage(t *testing.T) { | ||
type args struct { | ||
template string | ||
vars map[string]string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
wantBody string | ||
}{ | ||
{ | ||
name: "single line", | ||
args: args{ | ||
template: "Merge ${PullRequestTitle}", | ||
vars: map[string]string{ | ||
"PullRequestTitle": "PullRequestTitle", | ||
"PullRequestDescription": "Pull\nRequest\nDescription\n", | ||
}, | ||
}, | ||
want: "Merge PullRequestTitle", | ||
wantBody: "", | ||
}, | ||
{ | ||
name: "multiple lines", | ||
args: args{ | ||
template: "Merge ${PullRequestTitle}\nDescription:\n\n${PullRequestDescription}\n", | ||
vars: map[string]string{ | ||
"PullRequestTitle": "PullRequestTitle", | ||
"PullRequestDescription": "Pull\nRequest\nDescription\n", | ||
}, | ||
}, | ||
want: "Merge PullRequestTitle", | ||
wantBody: "Description:\n\nPull\nRequest\nDescription\n", | ||
}, | ||
{ | ||
name: "leading newlines", | ||
args: args{ | ||
template: "\n\n\nMerge ${PullRequestTitle}\n\n\nDescription:\n\n${PullRequestDescription}\n", | ||
vars: map[string]string{ | ||
"PullRequestTitle": "PullRequestTitle", | ||
"PullRequestDescription": "Pull\nRequest\nDescription\n", | ||
}, | ||
}, | ||
want: "Merge PullRequestTitle", | ||
wantBody: "Description:\n\nPull\nRequest\nDescription\n", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, got1 := expandDefaultMergeMessage(tt.args.template, tt.args.vars) | ||
assert.Equalf(t, tt.want, got, "expandDefaultMergeMessage(%v, %v)", tt.args.template, tt.args.vars) | ||
assert.Equalf(t, tt.wantBody, got1, "expandDefaultMergeMessage(%v, %v)", tt.args.template, tt.args.vars) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters