Fix ineffectual assignments

- Don't assign variables we don't end up using
- Added missing error check in test
pull/118/head
Christian Muehlhaeuser 2019-08-08 09:21:21 +00:00 committed by mattn
parent 1ccf66b8b4
commit 1b7f743892
4 changed files with 14 additions and 11 deletions

View File

@ -12,13 +12,13 @@ const wantBase64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHEAAABxCAYAAA
func TestBase64EncodeFileName(t *testing.T) { func TestBase64EncodeFileName(t *testing.T) {
// Error in os.Open. // Error in os.Open.
uri, err := Base64EncodeFileName("fail") _, err := Base64EncodeFileName("fail")
if err == nil { if err == nil {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
// Success. // Success.
uri, err = Base64EncodeFileName("testdata/logo.png") uri, err := Base64EncodeFileName("testdata/logo.png")
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }
@ -29,7 +29,7 @@ func TestBase64EncodeFileName(t *testing.T) {
func TestBase64Encode(t *testing.T) { func TestBase64Encode(t *testing.T) {
// Error in file.Stat. // Error in file.Stat.
uri, err := Base64Encode(nil) _, err := Base64Encode(nil)
if err == nil { if err == nil {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
@ -43,7 +43,7 @@ func TestBase64Encode(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }
uri, err = Base64Encode(logo) _, err = Base64Encode(logo)
if err == nil { if err == nil {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
@ -53,7 +53,7 @@ func TestBase64Encode(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }
uri, err = Base64Encode(logo) uri, err := Base64Encode(logo)
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }

View File

@ -57,11 +57,11 @@ func TestGetAccountLists(t *testing.T) {
ClientSecret: "bar", ClientSecret: "bar",
AccessToken: "zoo", AccessToken: "zoo",
}) })
lists, err := client.GetAccountLists(context.Background(), "2") _, err := client.GetAccountLists(context.Background(), "2")
if err == nil { if err == nil {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
lists, err = client.GetAccountLists(context.Background(), "1") lists, err := client.GetAccountLists(context.Background(), "1")
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }
@ -93,11 +93,11 @@ func TestGetListAccounts(t *testing.T) {
ClientSecret: "bar", ClientSecret: "bar",
AccessToken: "zoo", AccessToken: "zoo",
}) })
accounts, err := client.GetListAccounts(context.Background(), "2") _, err := client.GetListAccounts(context.Background(), "2")
if err == nil { if err == nil {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
accounts, err = client.GetListAccounts(context.Background(), "1") accounts, err := client.GetListAccounts(context.Background(), "1")
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }

View File

@ -609,6 +609,9 @@ func TestUploadMedia(t *testing.T) {
t.Fatalf("want %q but %q", "123", attachment.ID) t.Fatalf("want %q but %q", "123", attachment.ID)
} }
file, err := os.Open("testdata/logo.png") file, err := os.Open("testdata/logo.png")
if err != nil {
t.Fatalf("could not open file: %v", err)
}
defer file.Close() defer file.Close()
writerAttachment, err := client.UploadMediaFromReader(context.Background(), file) writerAttachment, err := client.UploadMediaFromReader(context.Background(), file)
if err != nil { if err != nil {

View File

@ -243,12 +243,12 @@ func TestDial(t *testing.T) {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
_, rawurl, err := client.dial("ws://" + ts.Listener.Addr().String()) _, _, err = client.dial("ws://" + ts.Listener.Addr().String())
if err == nil { if err == nil {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
_, rawurl, err = client.dial("ws://" + ts.Listener.Addr().String()) _, rawurl, err := client.dial("ws://" + ts.Listener.Addr().String())
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }