From 633f1e9872d4502746193f32a0ce0c59f4f66c4f Mon Sep 17 00:00:00 2001
From: Dmitry Savintsev <dsavints@gmail.com>
Date: Fri, 20 Jul 2018 15:21:03 +0200
Subject: [PATCH] fix go vet and gofmt issues with go1.11
github/repos_contents_test.go - use helper function to display string
or <nil> using string pointer.
github/misc_test.go - add a line break to allow passing gofmt check
with both go1.10 and go.11.
---
github/repos_contents_test.go | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go
index 0a08e8c7..29bab8d2 100644
--- a/github/repos_contents_test.go
+++ b/github/repos_contents_test.go
@@ -56,10 +56,12 @@ func TestRepositoryContent_GetContent(t *testing.T) {
r := RepositoryContent{Encoding: tt.encoding, Content: tt.content}
got, err := r.GetContent()
if err != nil && !tt.wantErr {
- t.Errorf("RepositoryContent(%q, %q) returned unexpected error: %v", tt.encoding, tt.content, err)
+ t.Errorf("RepositoryContent(%s, %s) returned unexpected error: %v",
+ stringOrNil(tt.encoding), stringOrNil(tt.content), err)
}
if err == nil && tt.wantErr {
- t.Errorf("RepositoryContent(%q, %q) did not return unexpected error", tt.encoding, tt.content)
+ t.Errorf("RepositoryContent(%s, %s) did not return unexpected error",
+ stringOrNil(tt.encoding), stringOrNil(tt.content))
}
if want := tt.want; got != want {
t.Errorf("RepositoryContent.GetContent returned %+v, want %+v", got, want)
@@ -67,6 +69,15 @@ func TestRepositoryContent_GetContent(t *testing.T) {
}
}
+// stringOrNil converts a potentially null string pointer to string.
+// For non-nil input pointer, the returned string is enclosed in double-quotes.
+func stringOrNil(s *string) string {
+ if s == nil {
+ return "<nil>"
+ }
+ return fmt.Sprintf("%q", *s)
+}
+
func TestRepositoriesService_GetReadme(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()