From e734186845418a986401ec1f71fac04f9c303458 Mon Sep 17 00:00:00 2001 From: Cyrille Hemidy Date: Tue, 13 Nov 2018 21:28:37 +0100 Subject: [PATCH 1/5] remove support go 1.6 --- auth/auth.go | 2 +- auth/auth_appengine.go | 3 ++- auth/auth_std.go | 3 ++- auth/auth_test.go | 2 +- auth/token_generator.go | 2 +- auth/token_generator_test.go | 2 +- auth/token_verifier.go | 5 ++--- auth/user_mgt.go | 3 ++- auth/user_mgt_test.go | 2 +- db/auth_override_test.go | 2 +- db/db.go | 3 ++- db/db_test.go | 3 ++- db/query.go | 2 +- db/query_test.go | 2 +- db/ref.go | 2 +- db/ref_test.go | 2 +- firebase.go | 2 +- firebase_test.go | 2 +- iid/iid.go | 2 +- iid/iid_test.go | 2 +- integration/auth/auth_test.go | 2 +- integration/auth/user_mgt_test.go | 2 +- integration/db/db_test.go | 2 +- integration/db/query_test.go | 2 +- integration/firestore/firestore_test.go | 2 +- integration/iid/iid_test.go | 2 +- integration/internal/internal.go | 2 +- integration/messaging/messaging_test.go | 2 +- integration/storage/storage_test.go | 2 +- internal/http_client.go | 6 ++---- internal/http_client_test.go | 2 +- messaging/messaging.go | 3 ++- messaging/messaging_test.go | 2 +- snippets/auth.go | 2 +- snippets/db.go | 2 +- snippets/init.go | 2 +- snippets/messaging.go | 2 +- snippets/storage.go | 2 +- storage/storage.go | 2 +- storage/storage_test.go | 2 +- 40 files changed, 48 insertions(+), 45 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index e73b33ac..869714ff 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -23,7 +23,7 @@ import ( "google.golang.org/api/option" - "golang.org/x/net/context" + "context" "firebase.google.com/go/internal" "google.golang.org/api/identitytoolkit/v3" diff --git a/auth/auth_appengine.go b/auth/auth_appengine.go index 6b0df95a..53834ed0 100644 --- a/auth/auth_appengine.go +++ b/auth/auth_appengine.go @@ -17,8 +17,9 @@ package auth import ( + "context" + "firebase.google.com/go/internal" - "golang.org/x/net/context" "google.golang.org/appengine" ) diff --git a/auth/auth_std.go b/auth/auth_std.go index 4e181ff9..7c757175 100644 --- a/auth/auth_std.go +++ b/auth/auth_std.go @@ -17,8 +17,9 @@ package auth // import "firebase.google.com/go/auth" import ( + "context" + "firebase.google.com/go/internal" - "golang.org/x/net/context" ) func newCryptoSigner(ctx context.Context, conf *internal.AuthConfig) (cryptoSigner, error) { diff --git a/auth/auth_test.go b/auth/auth_test.go index 40a54895..1cecf97f 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -25,7 +25,7 @@ import ( "testing" "time" - "golang.org/x/net/context" + "context" "golang.org/x/oauth2/google" diff --git a/auth/token_generator.go b/auth/token_generator.go index 38252850..6580ef3a 100644 --- a/auth/token_generator.go +++ b/auth/token_generator.go @@ -32,7 +32,7 @@ import ( "firebase.google.com/go/internal" "google.golang.org/api/transport" - "golang.org/x/net/context" + "context" ) type jwtHeader struct { diff --git a/auth/token_generator_test.go b/auth/token_generator_test.go index a2648f45..0e069ec6 100644 --- a/auth/token_generator_test.go +++ b/auth/token_generator_test.go @@ -28,7 +28,7 @@ import ( "firebase.google.com/go/internal" "google.golang.org/api/option" - "golang.org/x/net/context" + "context" ) func TestEncodeToken(t *testing.T) { diff --git a/auth/token_verifier.go b/auth/token_verifier.go index 97c0cc99..6960d0ab 100644 --- a/auth/token_verifier.go +++ b/auth/token_verifier.go @@ -32,8 +32,7 @@ import ( "sync" "time" - "golang.org/x/net/context" - "golang.org/x/net/context/ctxhttp" + "context" ) // keySource is used to obtain a set of public keys, which can be used to verify cryptographic @@ -89,7 +88,7 @@ func (k *httpKeySource) refreshKeys(ctx context.Context) error { return err } - resp, err := ctxhttp.Do(ctx, k.HTTPClient, req) + resp, err := k.HTTPClient.Do(req.WithContext(ctx)) if err != nil { return err } diff --git a/auth/user_mgt.go b/auth/user_mgt.go index 2939ca2e..2fae0b24 100644 --- a/auth/user_mgt.go +++ b/auth/user_mgt.go @@ -24,8 +24,9 @@ import ( "strings" "time" + "context" + "firebase.google.com/go/internal" - "golang.org/x/net/context" "google.golang.org/api/googleapi" "google.golang.org/api/identitytoolkit/v3" diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index ac9e5a99..6ab835ec 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "golang.org/x/net/context" + "context" "firebase.google.com/go/internal" diff --git a/db/auth_override_test.go b/db/auth_override_test.go index 86cbeef2..cd31f902 100644 --- a/db/auth_override_test.go +++ b/db/auth_override_test.go @@ -17,7 +17,7 @@ package db import ( "testing" - "golang.org/x/net/context" + "context" ) func TestAuthOverrideGet(t *testing.T) { diff --git a/db/db.go b/db/db.go index 6bed3922..f2dc721e 100644 --- a/db/db.go +++ b/db/db.go @@ -25,7 +25,8 @@ import ( "net/url" - "golang.org/x/net/context" + "context" + "google.golang.org/api/option" "google.golang.org/api/transport" ) diff --git a/db/db_test.go b/db/db_test.go index e811c9df..1d59db5f 100644 --- a/db/db_test.go +++ b/db/db_test.go @@ -23,7 +23,8 @@ import ( "runtime" "testing" - "golang.org/x/net/context" + "context" + "golang.org/x/oauth2" "encoding/json" diff --git a/db/query.go b/db/query.go index ce9a670b..525a2a58 100644 --- a/db/query.go +++ b/db/query.go @@ -24,7 +24,7 @@ import ( "firebase.google.com/go/internal" - "golang.org/x/net/context" + "context" ) // QueryNode represents a data node retrieved from an ordered query. diff --git a/db/query_test.go b/db/query_test.go index 4473daff..a7226bae 100644 --- a/db/query_test.go +++ b/db/query_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "golang.org/x/net/context" + "context" ) var sortableKeysResp = map[string]interface{}{ diff --git a/db/ref.go b/db/ref.go index 8fbadf84..a105d5db 100644 --- a/db/ref.go +++ b/db/ref.go @@ -22,7 +22,7 @@ import ( "firebase.google.com/go/internal" - "golang.org/x/net/context" + "context" ) // txnRetires is the maximum number of times a transaction is retried before giving up. Transaction diff --git a/db/ref_test.go b/db/ref_test.go index 8c489467..0c8f41f6 100644 --- a/db/ref_test.go +++ b/db/ref_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - "golang.org/x/net/context" + "context" ) type refOp func(r *Ref) error diff --git a/firebase.go b/firebase.go index 3c719073..310c43e4 100644 --- a/firebase.go +++ b/firebase.go @@ -23,7 +23,7 @@ import ( "io/ioutil" "os" - "golang.org/x/net/context" + "context" "cloud.google.com/go/firestore" diff --git a/firebase_test.go b/firebase_test.go index 9f8af9ac..df8d7d34 100644 --- a/firebase_test.go +++ b/firebase_test.go @@ -26,7 +26,7 @@ import ( "testing" "time" - "golang.org/x/net/context" + "context" "golang.org/x/oauth2/google" diff --git a/iid/iid.go b/iid/iid.go index 87b8c8ac..75e9183f 100644 --- a/iid/iid.go +++ b/iid/iid.go @@ -20,7 +20,7 @@ import ( "fmt" "net/http" - "golang.org/x/net/context" + "context" "google.golang.org/api/transport" diff --git a/iid/iid_test.go b/iid/iid_test.go index cfe21662..f1088cb1 100644 --- a/iid/iid_test.go +++ b/iid/iid_test.go @@ -20,7 +20,7 @@ import ( "net/http/httptest" "testing" - "golang.org/x/net/context" + "context" "google.golang.org/api/option" diff --git a/integration/auth/auth_test.go b/integration/auth/auth_test.go index 23740c99..409e90fd 100644 --- a/integration/auth/auth_test.go +++ b/integration/auth/auth_test.go @@ -31,7 +31,7 @@ import ( "golang.org/x/oauth2/google" - "golang.org/x/net/context" + "context" firebase "firebase.google.com/go" "firebase.google.com/go/auth" diff --git a/integration/auth/user_mgt_test.go b/integration/auth/user_mgt_test.go index d9a46951..6a1e14c1 100644 --- a/integration/auth/user_mgt_test.go +++ b/integration/auth/user_mgt_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "golang.org/x/net/context" + "context" "google.golang.org/api/iterator" diff --git a/integration/db/db_test.go b/integration/db/db_test.go index e5f61f04..db50c9f5 100644 --- a/integration/db/db_test.go +++ b/integration/db/db_test.go @@ -27,7 +27,7 @@ import ( "reflect" "testing" - "golang.org/x/net/context" + "context" "firebase.google.com/go" "firebase.google.com/go/db" diff --git a/integration/db/query_test.go b/integration/db/query_test.go index 6573d915..2c18c77c 100644 --- a/integration/db/query_test.go +++ b/integration/db/query_test.go @@ -21,7 +21,7 @@ import ( "reflect" - "golang.org/x/net/context" + "context" ) var heightSorted = []string{ diff --git a/integration/firestore/firestore_test.go b/integration/firestore/firestore_test.go index c89e68e6..6b232d0a 100644 --- a/integration/firestore/firestore_test.go +++ b/integration/firestore/firestore_test.go @@ -19,7 +19,7 @@ import ( "reflect" "testing" - "golang.org/x/net/context" + "context" "firebase.google.com/go/integration/internal" ) diff --git a/integration/iid/iid_test.go b/integration/iid/iid_test.go index a9c67e6f..e4249f6f 100644 --- a/integration/iid/iid_test.go +++ b/integration/iid/iid_test.go @@ -21,7 +21,7 @@ import ( "os" "testing" - "golang.org/x/net/context" + "context" "firebase.google.com/go/iid" "firebase.google.com/go/integration/internal" diff --git a/integration/internal/internal.go b/integration/internal/internal.go index 497065eb..3f501d39 100644 --- a/integration/internal/internal.go +++ b/integration/internal/internal.go @@ -23,7 +23,7 @@ import ( "path/filepath" "strings" - "golang.org/x/net/context" + "context" firebase "firebase.google.com/go" "firebase.google.com/go/internal" diff --git a/integration/messaging/messaging_test.go b/integration/messaging/messaging_test.go index 10818ddd..54b6de05 100644 --- a/integration/messaging/messaging_test.go +++ b/integration/messaging/messaging_test.go @@ -21,7 +21,7 @@ import ( "regexp" "testing" - "golang.org/x/net/context" + "context" "firebase.google.com/go/integration/internal" "firebase.google.com/go/messaging" diff --git a/integration/storage/storage_test.go b/integration/storage/storage_test.go index c47b29a8..68d07987 100644 --- a/integration/storage/storage_test.go +++ b/integration/storage/storage_test.go @@ -22,7 +22,7 @@ import ( "os" "testing" - "golang.org/x/net/context" + "context" "firebase.google.com/go" diff --git a/internal/http_client.go b/internal/http_client.go index 7f3df67a..5b7e938f 100644 --- a/internal/http_client.go +++ b/internal/http_client.go @@ -22,9 +22,7 @@ import ( "io/ioutil" "net/http" - "golang.org/x/net/context/ctxhttp" - - "golang.org/x/net/context" + "context" ) // HTTPClient is a convenient API to make HTTP calls. @@ -46,7 +44,7 @@ func (c *HTTPClient) Do(ctx context.Context, r *Request) (*Response, error) { return nil, err } - resp, err := ctxhttp.Do(ctx, c.Client, req) + resp, err := c.Client.Do(req.WithContext(ctx)) if err != nil { return nil, err } diff --git a/internal/http_client_test.go b/internal/http_client_test.go index bdac7474..109863bf 100644 --- a/internal/http_client_test.go +++ b/internal/http_client_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - "golang.org/x/net/context" + "context" ) var cases = []struct { diff --git a/messaging/messaging.go b/messaging/messaging.go index 8220d4a8..fe3c2a67 100644 --- a/messaging/messaging.go +++ b/messaging/messaging.go @@ -25,8 +25,9 @@ import ( "strings" "time" + "context" + "firebase.google.com/go/internal" - "golang.org/x/net/context" "google.golang.org/api/transport" ) diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index f71a1f73..f9b59ed4 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "golang.org/x/net/context" + "context" "firebase.google.com/go/internal" "google.golang.org/api/option" diff --git a/snippets/auth.go b/snippets/auth.go index cd98d701..8a82ab8f 100644 --- a/snippets/auth.go +++ b/snippets/auth.go @@ -18,7 +18,7 @@ import ( "encoding/base64" "log" - "golang.org/x/net/context" + "context" firebase "firebase.google.com/go" "firebase.google.com/go/auth" diff --git a/snippets/db.go b/snippets/db.go index c853e12a..2f5879c4 100644 --- a/snippets/db.go +++ b/snippets/db.go @@ -19,7 +19,7 @@ import ( "fmt" "log" - "golang.org/x/net/context" + "context" "firebase.google.com/go/db" diff --git a/snippets/init.go b/snippets/init.go index b6c6e232..63549e03 100644 --- a/snippets/init.go +++ b/snippets/init.go @@ -18,7 +18,7 @@ package snippets import ( "log" - "golang.org/x/net/context" + "context" firebase "firebase.google.com/go" "firebase.google.com/go/auth" diff --git a/snippets/messaging.go b/snippets/messaging.go index b3ce67d4..f72a50b8 100644 --- a/snippets/messaging.go +++ b/snippets/messaging.go @@ -19,7 +19,7 @@ import ( "log" "time" - "golang.org/x/net/context" + "context" "firebase.google.com/go" "firebase.google.com/go/messaging" diff --git a/snippets/storage.go b/snippets/storage.go index 169d56e4..e27a216f 100644 --- a/snippets/storage.go +++ b/snippets/storage.go @@ -17,7 +17,7 @@ package snippets import ( "log" - "golang.org/x/net/context" + "context" firebase "firebase.google.com/go" "google.golang.org/api/option" diff --git a/storage/storage.go b/storage/storage.go index 78019184..c21ad509 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -18,7 +18,7 @@ package storage // import "firebase.google.com/go/storage" import ( "errors" - "golang.org/x/net/context" + "context" "cloud.google.com/go/storage" "firebase.google.com/go/internal" diff --git a/storage/storage_test.go b/storage/storage_test.go index eff97a1b..49258873 100644 --- a/storage/storage_test.go +++ b/storage/storage_test.go @@ -17,7 +17,7 @@ package storage import ( "testing" - "golang.org/x/net/context" + "context" "google.golang.org/api/option" From 58ca392239d4bdd1266e2ed6441ceb46abf54799 Mon Sep 17 00:00:00 2001 From: Cyrille Hemidy Date: Tue, 13 Nov 2018 22:47:26 +0100 Subject: [PATCH 2/5] add subtests --- auth/auth_test.go | 18 ++++++---- db/query_test.go | 32 ++++++++++-------- db/ref_test.go | 20 ++++++----- firebase_test.go | 29 +++++++++------- integration/auth/user_mgt_test.go | 10 +++--- messaging/messaging_test.go | 56 ++++++++++++++++++------------- 6 files changed, 97 insertions(+), 68 deletions(-) diff --git a/auth/auth_test.go b/auth/auth_test.go index 1cecf97f..f070b898 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -205,10 +205,12 @@ func TestCustomTokenError(t *testing.T) { } for _, tc := range cases { - token, err := client.CustomTokenWithClaims(ctx, tc.uid, tc.claims) - if token != "" || err == nil { - t.Errorf("CustomTokenWithClaims(%q) = (%q, %v); want = (\"\", error)", tc.name, token, err) - } + t.Run(tc.name, func(t *testing.T) { + token, err := client.CustomTokenWithClaims(ctx, tc.uid, tc.claims) + if token != "" || err == nil { + t.Errorf("CustomTokenWithClaims(%q) = (%q, %v); want = (\"\", error)", tc.name, token, err) + } + }) } } @@ -321,9 +323,11 @@ func TestVerifyIDTokenError(t *testing.T) { } for _, tc := range cases { - if _, err := client.VerifyIDToken(ctx, tc.token); err == nil { - t.Errorf("VerifyIDToken(%q) = nil; want error", tc.name) - } + t.Run(tc.name, func(t *testing.T) { + if _, err := client.VerifyIDToken(ctx, tc.token); err == nil { + t.Errorf("VerifyIDToken(%q) = nil; want error", tc.name) + } + }) } } diff --git a/db/query_test.go b/db/query_test.go index a7226bae..b8d7384c 100644 --- a/db/query_test.go +++ b/db/query_test.go @@ -297,13 +297,15 @@ func TestInvalidLimitQuery(t *testing.T) { {"NegativeLast", q.LimitToLast(-10)}, } for _, tc := range cases { - var got map[string]interface{} - if err := tc.q.Get(context.Background(), &got); got != nil || err == nil { - t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err) - } - if len(mock.Reqs) != 0 { - t.Errorf("OrderByChild(%q): %v; want: empty", tc.name, mock.Reqs) - } + t.Run(tc.name, func(t *testing.T) { + var got map[string]interface{} + if err := tc.q.Get(context.Background(), &got); got != nil || err == nil { + t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err) + } + if len(mock.Reqs) != 0 { + t.Errorf("OrderByChild(%q): %v; want: empty", tc.name, mock.Reqs) + } + }) } } @@ -383,13 +385,15 @@ func TestInvalidFilterQuery(t *testing.T) { {"InvalidEqualTo", q.EqualTo(func() {})}, } for _, tc := range cases { - var got map[string]interface{} - if err := tc.q.Get(context.Background(), &got); got != nil || err == nil { - t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err) - } - if len(mock.Reqs) != 0 { - t.Errorf("OrdderByChild(%q) = %v; want = empty", tc.name, mock.Reqs) - } + t.Run(tc.name, func(t *testing.T) { + var got map[string]interface{} + if err := tc.q.Get(context.Background(), &got); got != nil || err == nil { + t.Errorf("OrderByChild(%q) = (%v, %v); want = (nil, error)", tc.name, got, err) + } + if len(mock.Reqs) != 0 { + t.Errorf("OrdderByChild(%q) = %v; want = empty", tc.name, mock.Reqs) + } + }) } } diff --git a/db/ref_test.go b/db/ref_test.go index 0c8f41f6..48237127 100644 --- a/db/ref_test.go +++ b/db/ref_test.go @@ -285,10 +285,12 @@ func TestWelformedHttpError(t *testing.T) { want := "http error status: 500; reason: test error" for _, tc := range testOps { - err := tc.op(testref) - if err == nil || err.Error() != want { - t.Errorf("%s = %v; want = %v", tc.name, err, want) - } + t.Run(tc.name, func(t *testing.T) { + err := tc.op(testref) + if err == nil || err.Error() != want { + t.Errorf("%s = %v; want = %v", tc.name, err, want) + } + }) } if len(mock.Reqs) != len(testOps) { @@ -303,10 +305,12 @@ func TestUnexpectedHttpError(t *testing.T) { want := "http error status: 500; reason: \"unexpected error\"" for _, tc := range testOps { - err := tc.op(testref) - if err == nil || err.Error() != want { - t.Errorf("%s = %v; want = %v", tc.name, err, want) - } + t.Run(tc.name, func(t *testing.T) { + err := tc.op(testref) + if err == nil || err.Error() != want { + t.Errorf("%s = %v; want = %v", tc.name, err, want) + } + }) } if len(mock.Reqs) != len(testOps) { diff --git a/firebase_test.go b/firebase_test.go index df8d7d34..3090d087 100644 --- a/firebase_test.go +++ b/firebase_test.go @@ -15,6 +15,7 @@ package firebase import ( + "fmt" "io/ioutil" "log" "net/http" @@ -557,13 +558,15 @@ func TestAutoInit(t *testing.T) { defer reinstateEnv(credEnvVar, credOld) for _, test := range tests { - overwriteEnv(firebaseEnvName, test.optionsConfig) - app, err := NewApp(context.Background(), test.initOptions) - if err != nil { - t.Errorf("NewApp(%s): %v", test.name, err) - } else { - compareConfig(app, test.wantOptions, t) - } + t.Run(fmt.Sprintf("NewApp(%s)", test.name), func(t *testing.T) { + overwriteEnv(firebaseEnvName, test.optionsConfig) + app, err := NewApp(context.Background(), test.initOptions) + if err != nil { + t.Error(err) + } else { + compareConfig(app, test.wantOptions, t) + } + }) } } @@ -593,11 +596,13 @@ func TestAutoInitInvalidFiles(t *testing.T) { defer reinstateEnv(credEnvVar, credOld) for _, test := range tests { - overwriteEnv(firebaseEnvName, test.filename) - _, err := NewApp(context.Background(), nil) - if err == nil || err.Error() != test.wantError { - t.Errorf("%s got error = %s; want = %s", test.name, err, test.wantError) - } + t.Run(test.name, func(t *testing.T) { + overwriteEnv(firebaseEnvName, test.filename) + _, err := NewApp(context.Background(), nil) + if err == nil || err.Error() != test.wantError { + t.Errorf("%s got error = %s; want = %s", test.name, err, test.wantError) + } + }) } } diff --git a/integration/auth/user_mgt_test.go b/integration/auth/user_mgt_test.go index 6a1e14c1..1cffc472 100644 --- a/integration/auth/user_mgt_test.go +++ b/integration/auth/user_mgt_test.go @@ -61,10 +61,12 @@ func TestGetUser(t *testing.T) { } for _, tc := range cases { - got, err := tc.getOp(context.Background()) - if err != nil || !reflect.DeepEqual(*got, *want) { - t.Errorf("%s = (%#v, %v); want = (%#v, nil)", tc.name, got, err, want) - } + t.Run(tc.name, func(t *testing.T) { + got, err := tc.getOp(context.Background()) + if err != nil || !reflect.DeepEqual(*got, *want) { + t.Errorf("%s = (%#v, %v); want = (%#v, nil)", tc.name, got, err, want) + } + }) } } diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index f9b59ed4..945c06f7 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -656,11 +656,13 @@ func TestSend(t *testing.T) { client.fcmEndpoint = ts.URL for _, tc := range validMessages { - name, err := client.Send(ctx, tc.req) - if name != testMessageID || err != nil { - t.Errorf("Send(%s) = (%q, %v); want = (%q, nil)", tc.name, name, err, testMessageID) - } - checkFCMRequest(t, b, tr, tc.want, false) + t.Run(tc.name, func(t *testing.T) { + name, err := client.Send(ctx, tc.req) + if name != testMessageID || err != nil { + t.Errorf("Send(%s) = (%q, %v); want = (%q, nil)", tc.name, name, err, testMessageID) + } + checkFCMRequest(t, b, tr, tc.want, false) + }) } } @@ -683,11 +685,13 @@ func TestSendDryRun(t *testing.T) { client.fcmEndpoint = ts.URL for _, tc := range validMessages { - name, err := client.SendDryRun(ctx, tc.req) - if name != testMessageID || err != nil { - t.Errorf("SendDryRun(%s) = (%q, %v); want = (%q, nil)", tc.name, name, err, testMessageID) - } - checkFCMRequest(t, b, tr, tc.want, true) + t.Run(tc.name, func(t *testing.T) { + name, err := client.SendDryRun(ctx, tc.req) + if name != testMessageID || err != nil { + t.Errorf("SendDryRun(%s) = (%q, %v); want = (%q, nil)", tc.name, name, err, testMessageID) + } + checkFCMRequest(t, b, tr, tc.want, true) + }) } } @@ -786,10 +790,12 @@ func TestInvalidMessage(t *testing.T) { t.Fatal(err) } for _, tc := range invalidMessages { - name, err := client.Send(ctx, tc.req) - if err == nil || err.Error() != tc.want { - t.Errorf("Send(%s) = (%q, %v); want = (%q, %q)", tc.name, name, err, "", tc.want) - } + t.Run(tc.name, func(t *testing.T) { + name, err := client.Send(ctx, tc.req) + if err == nil || err.Error() != tc.want { + t.Errorf("Send(%s) = (%q, %v); want = (%q, %q)", tc.name, name, err, "", tc.want) + } + }) } } @@ -826,10 +832,12 @@ func TestInvalidSubscribe(t *testing.T) { t.Fatal(err) } for _, tc := range invalidTopicMgtArgs { - name, err := client.SubscribeToTopic(ctx, tc.tokens, tc.topic) - if err == nil || err.Error() != tc.want { - t.Errorf("SubscribeToTopic(%s) = (%q, %v); want = (%q, %q)", tc.name, name, err, "", tc.want) - } + t.Run(tc.name, func(t *testing.T) { + name, err := client.SubscribeToTopic(ctx, tc.tokens, tc.topic) + if err == nil || err.Error() != tc.want { + t.Errorf("SubscribeToTopic(%s) = (%q, %v); want = (%q, %q)", tc.name, name, err, "", tc.want) + } + }) } } @@ -866,10 +874,12 @@ func TestInvalidUnsubscribe(t *testing.T) { t.Fatal(err) } for _, tc := range invalidTopicMgtArgs { - name, err := client.UnsubscribeFromTopic(ctx, tc.tokens, tc.topic) - if err == nil || err.Error() != tc.want { - t.Errorf("UnsubscribeFromTopic(%s) = (%q, %v); want = (%q, %q)", tc.name, name, err, "", tc.want) - } + t.Run(tc.name, func(t *testing.T) { + name, err := client.UnsubscribeFromTopic(ctx, tc.tokens, tc.topic) + if err == nil || err.Error() != tc.want { + t.Errorf("UnsubscribeFromTopic(%s) = (%q, %v); want = (%q, %q)", tc.name, name, err, "", tc.want) + } + }) } } @@ -965,7 +975,7 @@ func checkIIDRequest(t *testing.T, b []byte, tr *http.Request, op string) { t.Fatal(err) } want := map[string]interface{}{ - "to": "/topics/test-topic", + "to": "/topics/test-topic", "registration_tokens": []interface{}{"id1", "id2"}, } if !reflect.DeepEqual(parsed, want) { From 10ef2ba8ad3564d614538c742f917808beef0afc Mon Sep 17 00:00:00 2001 From: Cyrille Hemidy Date: Tue, 13 Nov 2018 22:51:42 +0100 Subject: [PATCH 3/5] fix gofmt --- messaging/messaging_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index 945c06f7..ef949758 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -975,7 +975,7 @@ func checkIIDRequest(t *testing.T, b []byte, tr *http.Request, op string) { t.Fatal(err) } want := map[string]interface{}{ - "to": "/topics/test-topic", + "to": "/topics/test-topic", "registration_tokens": []interface{}{"id1", "id2"}, } if !reflect.DeepEqual(parsed, want) { From 8e98d37410757a40cc367b73ccad779ebf4d808c Mon Sep 17 00:00:00 2001 From: Cyrille Hemidy Date: Wed, 14 Nov 2018 23:23:20 +0100 Subject: [PATCH 4/5] update changelog --- CHANGELOG.md | 2 ++ messaging/messaging_test.go | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b47918f..e0d31309 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +- [dropped] Dropped support for Go 1.8 and earlier. + # v3.4.0 - [added] `firebase.App` now provides a new `DatabaseWithURL()` function diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index ad1009b1..f274de2d 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -26,7 +26,6 @@ import ( "context" "firebase.google.com/go/internal" - "golang.org/x/net/context" "google.golang.org/api/option" ) From 4376f77c721c8b755e7848c26d8e0914a786baca Mon Sep 17 00:00:00 2001 From: Cyrille Hemidy Date: Wed, 14 Nov 2018 23:34:14 +0100 Subject: [PATCH 5/5] fix gofmt --- messaging/messaging_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index c4694640..6ef2fccf 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -15,6 +15,7 @@ package messaging import ( + "context" "encoding/json" "io/ioutil" "net/http" @@ -23,7 +24,6 @@ import ( "strings" "testing" "time" - "context" "firebase.google.com/go/internal" "google.golang.org/api/option"