Fewer todo literals

master
breel 2020-08-26 20:00:02 -06:00
parent 8efdaecf9a
commit c85465accf
5 changed files with 13 additions and 13 deletions

View File

@ -27,7 +27,7 @@ func TestGenerate(t *testing.T) {
ID: UserKey, ID: UserKey,
Title: key, 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) t.Fatal(err)
} }
r := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(UserKey+`=`+namespace)) r := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(UserKey+`=`+namespace))

View File

@ -43,7 +43,7 @@ func TestRegister(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
one, err := g.Get(context.TODO(), namespace, UserKey) one, err := g.Get(context.Background(), namespace, UserKey)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -13,7 +13,7 @@ import (
func TestScopeFromCtx(t *testing.T) { func TestScopeFromCtx(t *testing.T) {
var scope Scope var scope Scope
if ok := scope.fromCtx(context.TODO()); ok { if ok := scope.fromCtx(context.Background()); ok {
t.Fatal(ok) t.Fatal(ok)
} }
@ -22,7 +22,7 @@ func TestScopeFromCtx(t *testing.T) {
EntityName: uuid.New().String(), EntityName: uuid.New().String(),
EntityID: 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 { if ok := scope.fromCtx(ctx); !ok {
t.Fatal(ok) t.Fatal(ok)
} else if ctxScope != scope { } else if ctxScope != scope {
@ -109,7 +109,7 @@ func TestScopeFromGraph(t *testing.T) {
gEmpty := storage.NewRateLimitedGraph() gEmpty := storage.NewRateLimitedGraph()
gOne := 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) t.Fatal(err)
} }
@ -117,13 +117,13 @@ func TestScopeFromGraph(t *testing.T) {
Namespace: namespace, Namespace: namespace,
} }
if ok := scope.fromGraph(context.TODO(), gEmpty); ok { if ok := scope.fromGraph(context.Background(), gEmpty); ok {
t.Fatal(ok) t.Fatal(ok)
} else if scope.EntityName != "" { } else if scope.EntityName != "" {
t.Fatal(scope) t.Fatal(scope)
} }
if ok := scope.fromGraph(context.TODO(), gOne); ok { if ok := scope.fromGraph(context.Background(), gOne); ok {
t.Fatal(ok) t.Fatal(ok)
} else if scope.EntityName != "" { } else if scope.EntityName != "" {
t.Fatal(scope) t.Fatal(scope)
@ -131,13 +131,13 @@ func TestScopeFromGraph(t *testing.T) {
scope.EntityID = id scope.EntityID = id
if ok := scope.fromGraph(context.TODO(), gEmpty); ok { if ok := scope.fromGraph(context.Background(), gEmpty); ok {
t.Fatal(ok) t.Fatal(ok)
} else if scope.EntityName != "" { } else if scope.EntityName != "" {
t.Fatal(scope) t.Fatal(scope)
} }
if ok := scope.fromGraph(context.TODO(), gOne); !ok { if ok := scope.fromGraph(context.Background(), gOne); !ok {
t.Fatal(ok) t.Fatal(ok)
} else if scope.EntityName != name { } else if scope.EntityName != name {
t.Fatal(scope) t.Fatal(scope)

View File

@ -29,7 +29,7 @@ func TestVerify(t *testing.T) {
ID: token.ID, ID: token.ID,
Title: obf, 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) t.Fatal(err)
} }
return g, return g,
@ -119,7 +119,7 @@ func TestVerify(t *testing.T) {
t.Run("public not ok", func(t *testing.T) { t.Run("public not ok", func(t *testing.T) {
g, w, r, _, _ := fresh() 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) t.Fatal(err)
} }
err := Verify(g, w, r) err := Verify(g, w, r)
@ -130,7 +130,7 @@ func TestVerify(t *testing.T) {
t.Run("public ok", func(t *testing.T) { t.Run("public ok", func(t *testing.T) {
g, w, r, token, _ := fresh() 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) t.Fatal(err)
} }
token.ID = "gibberish-but-public-ns-so-its-ok" token.ID = "gibberish-but-public-ns-so-its-ok"

View File

@ -53,7 +53,7 @@ func TestMiddlewareDelay(t *testing.T) {
t.Fatal(time.Since(start)) t.Fatal(time.Since(start))
} }
ctx, can := context.WithCancel(context.TODO()) ctx, can := context.WithCancel(context.Background())
can() can()
r = r.WithContext(ctx) r = r.WithContext(ctx)