Fix ineffectual assignments
- Don't assign variables we don't end up using - Added missing error check in test
This commit is contained in:
parent
1ccf66b8b4
commit
1b7f743892
|
@ -12,13 +12,13 @@ const wantBase64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHEAAABxCAYAAA
|
|||
|
||||
func TestBase64EncodeFileName(t *testing.T) {
|
||||
// Error in os.Open.
|
||||
uri, err := Base64EncodeFileName("fail")
|
||||
_, err := Base64EncodeFileName("fail")
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
|
||||
// Success.
|
||||
uri, err = Base64EncodeFileName("testdata/logo.png")
|
||||
uri, err := Base64EncodeFileName("testdata/logo.png")
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func TestBase64EncodeFileName(t *testing.T) {
|
|||
|
||||
func TestBase64Encode(t *testing.T) {
|
||||
// Error in file.Stat.
|
||||
uri, err := Base64Encode(nil)
|
||||
_, err := Base64Encode(nil)
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func TestBase64Encode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
uri, err = Base64Encode(logo)
|
||||
_, err = Base64Encode(logo)
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func TestBase64Encode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
uri, err = Base64Encode(logo)
|
||||
uri, err := Base64Encode(logo)
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
|
|
@ -57,11 +57,11 @@ func TestGetAccountLists(t *testing.T) {
|
|||
ClientSecret: "bar",
|
||||
AccessToken: "zoo",
|
||||
})
|
||||
lists, err := client.GetAccountLists(context.Background(), "2")
|
||||
_, err := client.GetAccountLists(context.Background(), "2")
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
lists, err = client.GetAccountLists(context.Background(), "1")
|
||||
lists, err := client.GetAccountLists(context.Background(), "1")
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
@ -93,11 +93,11 @@ func TestGetListAccounts(t *testing.T) {
|
|||
ClientSecret: "bar",
|
||||
AccessToken: "zoo",
|
||||
})
|
||||
accounts, err := client.GetListAccounts(context.Background(), "2")
|
||||
_, err := client.GetListAccounts(context.Background(), "2")
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
accounts, err = client.GetListAccounts(context.Background(), "1")
|
||||
accounts, err := client.GetListAccounts(context.Background(), "1")
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
|
|
@ -609,6 +609,9 @@ func TestUploadMedia(t *testing.T) {
|
|||
t.Fatalf("want %q but %q", "123", attachment.ID)
|
||||
}
|
||||
file, err := os.Open("testdata/logo.png")
|
||||
if err != nil {
|
||||
t.Fatalf("could not open file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
writerAttachment, err := client.UploadMediaFromReader(context.Background(), file)
|
||||
if err != nil {
|
||||
|
|
|
@ -243,12 +243,12 @@ func TestDial(t *testing.T) {
|
|||
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 {
|
||||
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 {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user