Skip to content

Commit

Permalink
Add test for merge_upstream conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jun 21, 2023
1 parent 6ad15f8 commit 60df51b
Show file tree
Hide file tree
Showing 7 changed files with 789 additions and 13 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"kind": "Request",
"method": "POST",
"path": "/repos/ehuss/rust/merge-upstream",
"query": null,
"request_body": "{\"branch\":\"master\"}",
"response_code": 409,
"response_body": {
"documentation_url": "https://docs.github.com/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository",
"message": "There are merge conflicts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"kind": "Request",
"method": "GET",
"path": "/repos/rust-lang/rust/git/ref/heads/master",
"query": null,
"request_body": "",
"response_code": 200,
"response_body": {
"node_id": "MDM6UmVmNzI0NzEyOnJlZnMvaGVhZHMvbWFzdGVy",
"object": {
"sha": "b963a57205e548e8538a8182b1c273ea75007614",
"type": "commit",
"url": "https://api.github.com/repos/rust-lang/rust/git/commits/b963a57205e548e8538a8182b1c273ea75007614"
},
"ref": "refs/heads/master",
"url": "https://api.github.com/repos/rust-lang/rust/git/refs/heads/master"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"kind": "Request",
"method": "PATCH",
"path": "/repos/ehuss/rust/git/refs/heads/master",
"query": null,
"request_body": "{\"force\":true,\"sha\":\"b963a57205e548e8538a8182b1c273ea75007614\"}",
"response_code": 200,
"response_body": {
"node_id": "MDM6UmVmMTE3NDY0NjI1OnJlZnMvaGVhZHMvbWFzdGVy",
"object": {
"sha": "b963a57205e548e8538a8182b1c273ea75007614",
"type": "commit",
"url": "https://api.github.com/repos/ehuss/rust/git/commits/b963a57205e548e8538a8182b1c273ea75007614"
},
"ref": "refs/heads/master",
"url": "https://api.github.com/repos/ehuss/rust/git/refs/heads/master"
}
}
16 changes: 16 additions & 0 deletions tests/github_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ fn repository() {
assert_eq!(repo.fork, false);
assert_eq!(repo.owner(), "rust-lang");
assert_eq!(repo.name(), "rust");
assert!(repo.parent.is_none());

let repo = gh.repository("ehuss/rust").await.unwrap();
assert_eq!(repo.fork, true);
let parent = repo.parent.unwrap();
assert_eq!(parent.full_name, "rust-lang/rust");
assert_eq!(parent.fork, false);
});
}

Expand Down Expand Up @@ -365,6 +372,15 @@ fn merge_upstream() {
});
}

#[test]
fn merge_upstream_conflict() {
// Test when there is a merge conflict.
run_test("merge_upstream_conflict", |gh| async move {
let repo = gh.repository("ehuss/rust").await.unwrap();
repo.merge_upstream(&gh, "master").await.unwrap();
});
}

#[test]
fn user() {
run_test("user", |gh| async move {
Expand Down
26 changes: 13 additions & 13 deletions tests/github_client/repository/00-GET-repos_rust-lang_rust.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"downloads_url": "https://api.github.com/repos/rust-lang/rust/downloads",
"events_url": "https://api.github.com/repos/rust-lang/rust/events",
"fork": false,
"forks": 10257,
"forks_count": 10257,
"forks": 10902,
"forks_count": 10902,
"forks_url": "https://api.github.com/repos/rust-lang/rust/forks",
"full_name": "rust-lang/rust",
"git_commits_url": "https://api.github.com/repos/rust-lang/rust/git/commits{/sha}",
Expand Down Expand Up @@ -64,11 +64,11 @@
"milestones_url": "https://api.github.com/repos/rust-lang/rust/milestones{/number}",
"mirror_url": null,
"name": "rust",
"network_count": 10257,
"network_count": 10902,
"node_id": "MDEwOlJlcG9zaXRvcnk3MjQ3MTI=",
"notifications_url": "https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}",
"open_issues": 9527,
"open_issues_count": 9527,
"open_issues": 9613,
"open_issues_count": 9613,
"organization": {
"avatar_url": "https://avatars.githubusercontent.com/u/5430905?v=4",
"events_url": "https://api.github.com/users/rust-lang/events{/privacy}",
Expand Down Expand Up @@ -118,14 +118,14 @@
},
"private": false,
"pulls_url": "https://api.github.com/repos/rust-lang/rust/pulls{/number}",
"pushed_at": "2023-01-23T22:28:29Z",
"pushed_at": "2023-06-12T17:58:57Z",
"releases_url": "https://api.github.com/repos/rust-lang/rust/releases{/id}",
"size": 1057370,
"size": 894511,
"ssh_url": "[email protected]:rust-lang/rust.git",
"stargazers_count": 76867,
"stargazers_count": 82555,
"stargazers_url": "https://api.github.com/repos/rust-lang/rust/stargazers",
"statuses_url": "https://api.github.com/repos/rust-lang/rust/statuses/{sha}",
"subscribers_count": 1481,
"subscribers_count": 1496,
"subscribers_url": "https://api.github.com/repos/rust-lang/rust/subscribers",
"subscription_url": "https://api.github.com/repos/rust-lang/rust/subscription",
"svn_url": "https://github.com/rust-lang/rust",
Expand All @@ -138,11 +138,11 @@
"rust"
],
"trees_url": "https://api.github.com/repos/rust-lang/rust/git/trees{/sha}",
"updated_at": "2023-01-23T22:36:05Z",
"updated_at": "2023-06-12T17:54:18Z",
"url": "https://api.github.com/repos/rust-lang/rust",
"visibility": "public",
"watchers": 76867,
"watchers_count": 76867,
"watchers": 82555,
"watchers_count": 82555,
"web_commit_signoff_required": false
}
}
}
Loading

0 comments on commit 60df51b

Please sign in to comment.