Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

assert request params and body in pull_request_test#95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
juruen merged 1 commit intomainfromjuruen/pr-assert
Apr 4, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 70 additions & 14 deletionspkg/github/pullrequests_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -171,9 +171,17 @@ func Test_ListPullRequests(t *testing.T) {
{
name: "successful PRs listing",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.GetReposPullsByOwnerByRepo,
mockPRs,
expectQueryParams(t, map[string]string{
"state": "all",
"sort": "created",
"direction": "desc",
"per_page": "30",
"page": "1",
}).andThen(
mockResponse(t, http.StatusOK, mockPRs),
),
),
),
requestArgs: map[string]interface{}{
Expand DownExpand Up@@ -281,9 +289,15 @@ func Test_MergePullRequest(t *testing.T) {
{
name: "successful merge",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.PutReposPullsMergeByOwnerByRepoByPullNumber,
mockMergeResult,
expectRequestBody(t, map[string]interface{}{
"commit_title": "Merge PR #42",
"commit_message": "Merging awesome feature",
"merge_method": "squash",
}).andThen(
mockResponse(t, http.StatusOK, mockMergeResult),
),
),
),
requestArgs: map[string]interface{}{
Expand DownExpand Up@@ -662,7 +676,11 @@ func Test_UpdatePullRequestBranch(t *testing.T) {
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatchHandler(
mock.PutReposPullsUpdateBranchByOwnerByRepoByPullNumber,
mockResponse(t, http.StatusAccepted, mockUpdateResult),
expectRequestBody(t, map[string]interface{}{
"expected_head_sha": "abcd1234",
}).andThen(
mockResponse(t, http.StatusAccepted, mockUpdateResult),
),
),
),
requestArgs: map[string]interface{}{
Expand All@@ -679,7 +697,9 @@ func Test_UpdatePullRequestBranch(t *testing.T) {
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatchHandler(
mock.PutReposPullsUpdateBranchByOwnerByRepoByPullNumber,
mockResponse(t, http.StatusAccepted, mockUpdateResult),
expectRequestBody(t, map[string]interface{}{}).andThen(
mockResponse(t, http.StatusAccepted, mockUpdateResult),
),
),
),
requestArgs: map[string]interface{}{
Expand DownExpand Up@@ -1030,9 +1050,14 @@ func Test_CreatePullRequestReview(t *testing.T) {
{
name: "successful review creation with body only",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.PostReposPullsReviewsByOwnerByRepoByPullNumber,
mockReview,
expectRequestBody(t, map[string]interface{}{
"body": "Looks good!",
"event": "APPROVE",
}).andThen(
mockResponse(t, http.StatusOK, mockReview),
),
),
),
requestArgs: map[string]interface{}{
Expand All@@ -1048,9 +1073,15 @@ func Test_CreatePullRequestReview(t *testing.T) {
{
name: "successful review creation with commit_id",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.PostReposPullsReviewsByOwnerByRepoByPullNumber,
mockReview,
expectRequestBody(t, map[string]interface{}{
"body": "Looks good!",
"event": "APPROVE",
"commit_id": "abcdef123456",
}).andThen(
mockResponse(t, http.StatusOK, mockReview),
),
),
),
requestArgs: map[string]interface{}{
Expand All@@ -1067,9 +1098,26 @@ func Test_CreatePullRequestReview(t *testing.T) {
{
name: "successful review creation with comments",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.PostReposPullsReviewsByOwnerByRepoByPullNumber,
mockReview,
expectRequestBody(t, map[string]interface{}{
"body": "Some issues to fix",
"event": "REQUEST_CHANGES",
"comments": []interface{}{
map[string]interface{}{
"path": "file1.go",
"position": float64(10),
"body": "This needs to be fixed",
},
map[string]interface{}{
"path": "file2.go",
"position": float64(20),
"body": "Consider a different approach here",
},
},
}).andThen(
mockResponse(t, http.StatusOK, mockReview),
),
),
),
requestArgs: map[string]interface{}{
Expand DownExpand Up@@ -1240,10 +1288,18 @@ func Test_CreatePullRequest(t *testing.T) {
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatchHandler(
mock.PostReposPullsByOwnerByRepo,
mockResponse(t, http.StatusCreated, mockPR),
expectRequestBody(t, map[string]interface{}{
"title": "Test PR",
"body": "This is a test PR",
"head": "feature-branch",
"base": "main",
"draft": false,
"maintainer_can_modify": true,
}).andThen(
mockResponse(t, http.StatusCreated, mockPR),
),
),
),

requestArgs: map[string]interface{}{
"owner": "owner",
"repo": "repo",
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp