diff --git a/server/auth/generate_test.go b/server/auth/generate_test.go index cec99fc..12f6c24 100644 --- a/server/auth/generate_test.go +++ b/server/auth/generate_test.go @@ -27,7 +27,7 @@ func TestGenerate(t *testing.T) { ID: UserKey, Title: key, } - if err := g.Insert(context.TODO(), namespace, one); err != nil { + if err := g.Insert(context.Background(), namespace, one); err != nil { t.Fatal(err) } r := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(UserKey+`=`+namespace)) diff --git a/server/auth/register_test.go b/server/auth/register_test.go index 90cc732..539da46 100644 --- a/server/auth/register_test.go +++ b/server/auth/register_test.go @@ -43,7 +43,7 @@ func TestRegister(t *testing.T) { if err != nil { t.Fatal(err) } - one, err := g.Get(context.TODO(), namespace, UserKey) + one, err := g.Get(context.Background(), namespace, UserKey) if err != nil { t.Fatal(err) } diff --git a/server/auth/scope_test.go b/server/auth/scope_test.go index c019e7f..9dfb516 100644 --- a/server/auth/scope_test.go +++ b/server/auth/scope_test.go @@ -13,7 +13,7 @@ import ( func TestScopeFromCtx(t *testing.T) { var scope Scope - if ok := scope.fromCtx(context.TODO()); ok { + if ok := scope.fromCtx(context.Background()); ok { t.Fatal(ok) } @@ -22,7 +22,7 @@ func TestScopeFromCtx(t *testing.T) { EntityName: uuid.New().String(), EntityID: uuid.New().String(), } - ctx := context.WithValue(context.TODO(), ScopeKey, ctxScope) + ctx := context.WithValue(context.Background(), ScopeKey, ctxScope) if ok := scope.fromCtx(ctx); !ok { t.Fatal(ok) } else if ctxScope != scope { @@ -109,7 +109,7 @@ func TestScopeFromGraph(t *testing.T) { gEmpty := storage.NewRateLimitedGraph() gOne := storage.NewRateLimitedGraph() - if err := gOne.Insert(context.TODO(), namespace, entity.One{ID: id, Name: name}); err != nil { + if err := gOne.Insert(context.Background(), namespace, entity.One{ID: id, Name: name}); err != nil { t.Fatal(err) } @@ -117,13 +117,13 @@ func TestScopeFromGraph(t *testing.T) { Namespace: namespace, } - if ok := scope.fromGraph(context.TODO(), gEmpty); ok { + if ok := scope.fromGraph(context.Background(), gEmpty); ok { t.Fatal(ok) } else if scope.EntityName != "" { t.Fatal(scope) } - if ok := scope.fromGraph(context.TODO(), gOne); ok { + if ok := scope.fromGraph(context.Background(), gOne); ok { t.Fatal(ok) } else if scope.EntityName != "" { t.Fatal(scope) @@ -131,13 +131,13 @@ func TestScopeFromGraph(t *testing.T) { scope.EntityID = id - if ok := scope.fromGraph(context.TODO(), gEmpty); ok { + if ok := scope.fromGraph(context.Background(), gEmpty); ok { t.Fatal(ok) } else if scope.EntityName != "" { t.Fatal(scope) } - if ok := scope.fromGraph(context.TODO(), gOne); !ok { + if ok := scope.fromGraph(context.Background(), gOne); !ok { t.Fatal(ok) } else if scope.EntityName != name { t.Fatal(scope) diff --git a/server/auth/verify_test.go b/server/auth/verify_test.go index 21af40e..8a42af7 100644 --- a/server/auth/verify_test.go +++ b/server/auth/verify_test.go @@ -29,7 +29,7 @@ func TestVerify(t *testing.T) { ID: token.ID, Title: obf, } - if err := g.Insert(context.TODO(), token.Namespace+"."+AuthKey, one); err != nil { + if err := g.Insert(context.Background(), token.Namespace+"."+AuthKey, one); err != nil { t.Fatal(err) } return g, @@ -119,7 +119,7 @@ func TestVerify(t *testing.T) { t.Run("public not ok", func(t *testing.T) { g, w, r, _, _ := fresh() - if err := g.Insert(context.TODO(), "public", entity.One{ID: UserKey}); err != nil { + if err := g.Insert(context.Background(), "public", entity.One{ID: UserKey}); err != nil { t.Fatal(err) } err := Verify(g, w, r) @@ -130,7 +130,7 @@ func TestVerify(t *testing.T) { t.Run("public ok", func(t *testing.T) { g, w, r, token, _ := fresh() - if err := g.Insert(context.TODO(), token.Namespace, entity.One{ID: UserKey}); err != nil { + if err := g.Insert(context.Background(), token.Namespace, entity.One{ID: UserKey}); err != nil { t.Fatal(err) } token.ID = "gibberish-but-public-ns-so-its-ok" diff --git a/server/middleware_test.go b/server/middleware_test.go index 604fa03..82675b7 100644 --- a/server/middleware_test.go +++ b/server/middleware_test.go @@ -53,7 +53,7 @@ func TestMiddlewareDelay(t *testing.T) { t.Fatal(time.Since(start)) } - ctx, can := context.WithCancel(context.TODO()) + ctx, can := context.WithCancel(context.Background()) can() r = r.WithContext(ctx)