From aacf907cae3fc95a86cabb933125c0d76f210f57 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Mon, 12 Dec 2016 16:50:58 -0500 Subject: [PATCH] Fix inverted logic in TestRepositoriesService_CompareCommits. Previously, the test would pass if got and want were different, and fail if they were equal. Closes #491. Change-Id: Ie9b0059595ef85777613578b06c98c10104f4e6a --- github/repos_commits_test.go | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 47224df..83f8f29 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -180,7 +180,7 @@ func TestRepositoriesService_CompareCommits(t *testing.T) { "message": "m", "tree": { "sha": "t" } }, - "author": { "login": "n" }, + "author": { "login": "l" }, "committer": { "login": "l" }, "parents": [ { "sha": "s" } ] }, @@ -207,21 +207,39 @@ func TestRepositoriesService_CompareCommits(t *testing.T) { } want := &CommitsComparison{ - Status: String("s"), - AheadBy: Int(1), - BehindBy: Int(2), - TotalCommits: Int(1), BaseCommit: &RepositoryCommit{ + SHA: String("s"), Commit: &Commit{ - Author: &CommitAuthor{Name: String("n")}, + Author: &CommitAuthor{Name: String("n")}, + Committer: &CommitAuthor{Name: String("n")}, + Message: String("m"), + Tree: &Tree{SHA: String("t")}, }, Author: &User{Login: String("l")}, Committer: &User{Login: String("l")}, - Message: String("m"), + Parents: []Commit{ + { + SHA: String("s"), + }, + }, }, + Status: String("s"), + AheadBy: Int(1), + BehindBy: Int(2), + TotalCommits: Int(1), Commits: []RepositoryCommit{ { SHA: String("s"), + Commit: &Commit{ + Author: &CommitAuthor{Name: String("n")}, + }, + Author: &User{Login: String("l")}, + Committer: &User{Login: String("l")}, + Parents: []Commit{ + { + SHA: String("s"), + }, + }, }, }, Files: []CommitFile{ @@ -231,7 +249,7 @@ func TestRepositoriesService_CompareCommits(t *testing.T) { }, } - if reflect.DeepEqual(got, want) { + if !reflect.DeepEqual(got, want) { t.Errorf("Repositories.CompareCommits returned \n%+v, want \n%+v", got, want) } }