macaroons: drop unused variables in tests

macaroons: defer service.Close() after error check in tests

macaroons: linter requires that nil contexts are changed to context.TODO()
This commit is contained in:
Lars Lehtonen committed 2019-10-11 09:39:11 -07:00
1 parent 20a5ee2f1e
commit 3587325438
2 files changed
+18 -14

No files matched your search

+9 -8
View File
@@ -2,6 +2,7 @@ package macaroons_test
import (
"bytes"
"context"
"io/ioutil"
"os"
"path"
@@ -34,12 +35,12 @@ func TestStore(t *testing.T) {
}
defer store.Close()
key, id, err := store.RootKey(nil)
_, _, err = store.RootKey(context.TODO())
if err != macaroons.ErrStoreLocked {
t.Fatalf("Received %v instead of ErrStoreLocked", err)
}
key, err = store.Get(nil, nil)
_, err = store.Get(context.TODO(), nil)
if err != macaroons.ErrStoreLocked {
t.Fatalf("Received %v instead of ErrStoreLocked", err)
}
@@ -50,13 +51,13 @@ func TestStore(t *testing.T) {
t.Fatalf("Error creating store encryption key: %v", err)
}
key, id, err = store.RootKey(nil)
key, id, err := store.RootKey(context.TODO())
if err != nil {
t.Fatalf("Error getting root key from store: %v", err)
}
rootID := id
key2, err := store.Get(nil, id)
key2, err := store.Get(context.TODO(), id)
if err != nil {
t.Fatalf("Error getting key with ID %s: %v", string(id), err)
}
@@ -97,12 +98,12 @@ func TestStore(t *testing.T) {
t.Fatalf("Received %v instead of ErrPasswordRequired", err)
}
key, id, err = store.RootKey(nil)
_, _, err = store.RootKey(context.TODO())
if err != macaroons.ErrStoreLocked {
t.Fatalf("Received %v instead of ErrStoreLocked", err)
}
key, err = store.Get(nil, nil)
_, err = store.Get(context.TODO(), nil)
if err != macaroons.ErrStoreLocked {
t.Fatalf("Received %v instead of ErrStoreLocked", err)
}
@@ -112,7 +113,7 @@ func TestStore(t *testing.T) {
t.Fatalf("Error unlocking root key store: %v", err)
}
key, err = store.Get(nil, rootID)
key, err = store.Get(context.TODO(), rootID)
if err != nil {
t.Fatalf("Error getting key with ID %s: %v",
string(rootID), err)
@@ -122,7 +123,7 @@ func TestStore(t *testing.T) {
key2, key)
}
key, id, err = store.RootKey(nil)
key, id, err = store.RootKey(context.TODO())
if err != nil {
t.Fatalf("Error getting root key from store: %v", err)
}