Skip to content

Commit ae61f62

Browse files
chemidyhiranya911
authored andcommitted
Inline errors check (#274)
* add New options * inline error check * inline error check * revert additions to the FCM API
1 parent 25e7c82 commit ae61f62

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

auth/email_action_links_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,16 @@ func TestEmailSignInLink(t *testing.T) {
204204

205205
func TestEmailActionLinkNoEmail(t *testing.T) {
206206
client := &Client{}
207-
_, err := client.EmailVerificationLink(context.Background(), "")
208-
if err == nil {
207+
208+
if _, err := client.EmailVerificationLink(context.Background(), ""); err == nil {
209209
t.Errorf("EmailVerificationLink('') = nil; want error")
210210
}
211211

212-
_, err = client.PasswordResetLink(context.Background(), "")
213-
if err == nil {
212+
if _, err := client.PasswordResetLink(context.Background(), ""); err == nil {
214213
t.Errorf("PasswordResetLink('') = nil; want error")
215214
}
216215

217-
_, err = client.EmailSignInLink(context.Background(), "", testActionCodeSettings)
218-
if err == nil {
216+
if _, err := client.EmailSignInLink(context.Background(), "", testActionCodeSettings); err == nil {
219217
t.Errorf("EmailSignInLink('') = nil; want error")
220218
}
221219
}
@@ -252,8 +250,7 @@ func TestEmailSignInLinkInvalidSettings(t *testing.T) {
252250

253251
func TestEmailSignInLinkNoSettings(t *testing.T) {
254252
client := &Client{}
255-
_, err := client.EmailSignInLink(context.Background(), testEmail, nil)
256-
if err == nil {
253+
if _, err := client.EmailSignInLink(context.Background(), testEmail, nil); err == nil {
257254
t.Errorf("EmailSignInLink(nil) = %v; want = error", err)
258255
}
259256
}

auth/user_mgt_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,26 +1142,23 @@ func TestSessionCookieWithoutProjectID(t *testing.T) {
11421142

11431143
func TestSessionCookieWithoutIDToken(t *testing.T) {
11441144
client := &Client{}
1145-
_, err := client.SessionCookie(context.Background(), "", 10*time.Minute)
1146-
if err == nil {
1145+
if _, err := client.SessionCookie(context.Background(), "", 10*time.Minute); err == nil {
11471146
t.Errorf("CreateSessionCookie('') = nil; want error")
11481147
}
11491148
}
11501149

11511150
func TestSessionCookieShortExpiresIn(t *testing.T) {
11521151
client := &Client{}
11531152
lessThanFiveMins := 5*time.Minute - time.Second
1154-
_, err := client.SessionCookie(context.Background(), "idToken", lessThanFiveMins)
1155-
if err == nil {
1153+
if _, err := client.SessionCookie(context.Background(), "idToken", lessThanFiveMins); err == nil {
11561154
t.Errorf("SessionCookie(< 5 mins) = nil; want error")
11571155
}
11581156
}
11591157

11601158
func TestSessionCookieLongExpiresIn(t *testing.T) {
11611159
client := &Client{}
11621160
moreThanTwoWeeks := 14*24*time.Hour + time.Second
1163-
_, err := client.SessionCookie(context.Background(), "idToken", moreThanTwoWeeks)
1164-
if err == nil {
1161+
if _, err := client.SessionCookie(context.Background(), "idToken", moreThanTwoWeeks); err == nil {
11651162
t.Errorf("SessionCookie(> 14 days) = nil; want error")
11661163
}
11671164
}

internal/http_client_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,7 @@ func TestInvalidURL(t *testing.T) {
486486
URL: "http://localhost:250/mock.url",
487487
}
488488
client := &HTTPClient{Client: http.DefaultClient}
489-
_, err := client.Do(context.Background(), req)
490-
if err == nil {
489+
if _, err := client.Do(context.Background(), req); err == nil {
491490
t.Errorf("Send() = nil; want error")
492491
}
493492
}

messaging/messaging_batch_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,7 @@ func TestSendAllNonMultipartResponse(t *testing.T) {
359359
t.Fatal(err)
360360
}
361361
client.batchEndpoint = ts.URL
362-
363-
_, err = client.SendAll(ctx, testMessages)
364-
if err == nil {
362+
if _, err = client.SendAll(ctx, testMessages); err == nil {
365363
t.Fatal("SendAll() = nil; want = error")
366364
}
367365
}
@@ -379,9 +377,7 @@ func TestSendAllMalformedContentType(t *testing.T) {
379377
t.Fatal(err)
380378
}
381379
client.batchEndpoint = ts.URL
382-
383-
_, err = client.SendAll(ctx, testMessages)
384-
if err == nil {
380+
if _, err = client.SendAll(ctx, testMessages); err == nil {
385381
t.Fatal("SendAll() = nil; want = error")
386382
}
387383
}
@@ -405,9 +401,7 @@ func TestSendAllMalformedMultipartResponse(t *testing.T) {
405401
t.Fatal(err)
406402
}
407403
client.batchEndpoint = ts.URL
408-
409-
_, err = client.SendAll(ctx, testMessages)
410-
if err == nil {
404+
if _, err = client.SendAll(ctx, testMessages); err == nil {
411405
t.Fatal("SendAll() = nil; want = error")
412406
}
413407
}

0 commit comments

Comments
 (0)