Skip to content

Commit bee8866

Browse files
fix compare tests (#229)
The compare tests failed if the commits on master branch were merge commits. This fixes the tests by checking the latest commit on master branch and changing the test conditions accordingly. --------- Co-authored-by: Dilum Aluthge <[email protected]>
1 parent 97a4ad1 commit bee8866

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/read_only_api_tests.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,21 @@ end
8686
@test hasghobj("master", first(branches(ghjl; auth = auth)))
8787

8888
# test GitHub.compare
89-
@test compare(ghjl, "master", "master~"; auth = auth).behind_by == 1
90-
let comparison = compare(ghjl, "master~", "master"; auth = auth)
91-
@test comparison.ahead_by == 1
92-
@test length(comparison.commits) == 1
89+
# check if the latest commit is a merge commit
90+
latest_commit = GitHub.branch(ghjl, "master"; auth=auth).commit
91+
is_latest_commit_merge = length(latest_commit.parents) > 1
92+
if is_latest_commit_merge
93+
@test compare(ghjl, "master", "master~"; auth = auth).behind_by >= 1
94+
let comparison = compare(ghjl, "master~", "master"; auth = auth)
95+
@test comparison.ahead_by >= 1
96+
@test length(comparison.commits) >= 1
97+
end
98+
else
99+
@test compare(ghjl, "master", "master~"; auth = auth).behind_by == 1
100+
let comparison = compare(ghjl, "master~", "master"; auth = auth)
101+
@test comparison.ahead_by == 1
102+
@test length(comparison.commits) == 1
103+
end
93104
end
94105

95106
# test GitHub.file, GitHub.directory, GitHub.readme, GitHub.permalink

0 commit comments

Comments
 (0)