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,
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))

View File

@ -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)
}

View File

@ -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)

View File

@ -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"

View File

@ -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)