Skip to content

Commit 9f14128

Browse files
committed
Add test for merge_upstream conflict.
1 parent 44b0496 commit 9f14128

7 files changed

+789
-13
lines changed

tests/github_client/merge_upstream_conflict/00-GET-repos_ehuss_rust.json

Lines changed: 356 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"kind": "Request",
3+
"method": "POST",
4+
"path": "/repos/ehuss/rust/merge-upstream",
5+
"query": null,
6+
"request_body": "{\"branch\":\"master\"}",
7+
"response_code": 409,
8+
"response_body": {
9+
"documentation_url": "https://docs.github.com/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository",
10+
"message": "There are merge conflicts"
11+
}
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"kind": "Request",
3+
"method": "GET",
4+
"path": "/repos/rust-lang/rust/git/ref/heads/master",
5+
"query": null,
6+
"request_body": "",
7+
"response_code": 200,
8+
"response_body": {
9+
"node_id": "MDM6UmVmNzI0NzEyOnJlZnMvaGVhZHMvbWFzdGVy",
10+
"object": {
11+
"sha": "b963a57205e548e8538a8182b1c273ea75007614",
12+
"type": "commit",
13+
"url": "https://api.github.com/repos/rust-lang/rust/git/commits/b963a57205e548e8538a8182b1c273ea75007614"
14+
},
15+
"ref": "refs/heads/master",
16+
"url": "https://api.github.com/repos/rust-lang/rust/git/refs/heads/master"
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"kind": "Request",
3+
"method": "PATCH",
4+
"path": "/repos/ehuss/rust/git/refs/heads/master",
5+
"query": null,
6+
"request_body": "{\"force\":true,\"sha\":\"b963a57205e548e8538a8182b1c273ea75007614\"}",
7+
"response_code": 200,
8+
"response_body": {
9+
"node_id": "MDM6UmVmMTE3NDY0NjI1OnJlZnMvaGVhZHMvbWFzdGVy",
10+
"object": {
11+
"sha": "b963a57205e548e8538a8182b1c273ea75007614",
12+
"type": "commit",
13+
"url": "https://api.github.com/repos/ehuss/rust/git/commits/b963a57205e548e8538a8182b1c273ea75007614"
14+
},
15+
"ref": "refs/heads/master",
16+
"url": "https://api.github.com/repos/ehuss/rust/git/refs/heads/master"
17+
}
18+
}

tests/github_client/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ fn repository() {
134134
assert_eq!(repo.fork, false);
135135
assert_eq!(repo.owner(), "rust-lang");
136136
assert_eq!(repo.name(), "rust");
137+
assert!(repo.parent.is_none());
138+
139+
let repo = gh.repository("ehuss/rust").await.unwrap();
140+
assert_eq!(repo.fork, true);
141+
let parent = repo.parent.unwrap();
142+
assert_eq!(parent.full_name, "rust-lang/rust");
143+
assert_eq!(parent.fork, false);
137144
});
138145
}
139146

@@ -365,6 +372,15 @@ fn merge_upstream() {
365372
});
366373
}
367374

375+
#[test]
376+
fn merge_upstream_conflict() {
377+
// Test when there is a merge conflict.
378+
run_test("merge_upstream_conflict", |gh| async move {
379+
let repo = gh.repository("ehuss/rust").await.unwrap();
380+
repo.merge_upstream(&gh, "master").await.unwrap();
381+
});
382+
}
383+
368384
#[test]
369385
fn user() {
370386
run_test("user", |gh| async move {

tests/github_client/repository/00-GET-repos_rust-lang_rust.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"downloads_url": "https://api.github.com/repos/rust-lang/rust/downloads",
2828
"events_url": "https://api.github.com/repos/rust-lang/rust/events",
2929
"fork": false,
30-
"forks": 10257,
31-
"forks_count": 10257,
30+
"forks": 10902,
31+
"forks_count": 10902,
3232
"forks_url": "https://api.github.com/repos/rust-lang/rust/forks",
3333
"full_name": "rust-lang/rust",
3434
"git_commits_url": "https://api.github.com/repos/rust-lang/rust/git/commits{/sha}",
@@ -64,11 +64,11 @@
6464
"milestones_url": "https://api.github.com/repos/rust-lang/rust/milestones{/number}",
6565
"mirror_url": null,
6666
"name": "rust",
67-
"network_count": 10257,
67+
"network_count": 10902,
6868
"node_id": "MDEwOlJlcG9zaXRvcnk3MjQ3MTI=",
6969
"notifications_url": "https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}",
70-
"open_issues": 9527,
71-
"open_issues_count": 9527,
70+
"open_issues": 9613,
71+
"open_issues_count": 9613,
7272
"organization": {
7373
"avatar_url": "https://avatars.githubusercontent.com/u/5430905?v=4",
7474
"events_url": "https://api.github.com/users/rust-lang/events{/privacy}",
@@ -118,14 +118,14 @@
118118
},
119119
"private": false,
120120
"pulls_url": "https://api.github.com/repos/rust-lang/rust/pulls{/number}",
121-
"pushed_at": "2023-01-23T22:28:29Z",
121+
"pushed_at": "2023-06-12T17:58:57Z",
122122
"releases_url": "https://api.github.com/repos/rust-lang/rust/releases{/id}",
123-
"size": 1057370,
123+
"size": 894511,
124124
"ssh_url": "[email protected]:rust-lang/rust.git",
125-
"stargazers_count": 76867,
125+
"stargazers_count": 82555,
126126
"stargazers_url": "https://api.github.com/repos/rust-lang/rust/stargazers",
127127
"statuses_url": "https://api.github.com/repos/rust-lang/rust/statuses/{sha}",
128-
"subscribers_count": 1481,
128+
"subscribers_count": 1496,
129129
"subscribers_url": "https://api.github.com/repos/rust-lang/rust/subscribers",
130130
"subscription_url": "https://api.github.com/repos/rust-lang/rust/subscription",
131131
"svn_url": "https://github.com/rust-lang/rust",
@@ -138,11 +138,11 @@
138138
"rust"
139139
],
140140
"trees_url": "https://api.github.com/repos/rust-lang/rust/git/trees{/sha}",
141-
"updated_at": "2023-01-23T22:36:05Z",
141+
"updated_at": "2023-06-12T17:54:18Z",
142142
"url": "https://api.github.com/repos/rust-lang/rust",
143143
"visibility": "public",
144-
"watchers": 76867,
145-
"watchers_count": 76867,
144+
"watchers": 82555,
145+
"watchers_count": 82555,
146146
"web_commit_signoff_required": false
147147
}
148-
}
148+
}

0 commit comments

Comments
 (0)