diff --git a/clients/p2p/auth/inject_test.go b/clients/p2p/auth/inject_test.go index 9ecf21db..85be92e0 100644 --- a/clients/p2p/auth/inject_test.go +++ b/clients/p2p/auth/inject_test.go @@ -14,8 +14,6 @@ import ( "gotest.tools/v3/assert" ) -var testDir = "testdir" // TODO: use temp - func injectCert(t *testing.T, client authIface.Client) []byte { cert, key, err := helpers.GenerateCert("*.pass.com") assert.NilError(t, err) @@ -40,12 +38,14 @@ func injectCert(t *testing.T, client authIface.Client) []byte { } func TestInject(t *testing.T) { + testDir, err := os.MkdirTemp("", "testdir") + assert.NilError(t, err) defer os.Remove(testDir) u := dream.New(dream.UniverseConfig{Name: t.Name()}) defer u.Stop() - err := u.StartWithConfig(&dream.Config{ + err = u.StartWithConfig(&dream.Config{ Services: map[string]commonIface.ServiceConfig{ "auth": {}, "tns": {}, @@ -58,16 +58,10 @@ func TestInject(t *testing.T) { }, }, }) - if err != nil { - t.Error(err) - return - } + assert.NilError(t, err) simple, err := u.Simple("client") - if err != nil { - t.Error(err) - return - } + assert.NilError(t, err) auth, err := simple.Auth() assert.NilError(t, err) @@ -75,10 +69,7 @@ func TestInject(t *testing.T) { cert := injectCert(t, auth) newStore, err := store.New(u.Context(), simple.PeerNode(), testDir, err) - if err != nil { - t.Error(err) - return - } + assert.NilError(t, err) // Shoud Fail _, err = newStore.Get(u.Context(), "test.fail.com") @@ -89,10 +80,7 @@ func TestInject(t *testing.T) { // Should Pass data, err := newStore.Get(u.Context(), "test.pass.com") - if err != nil { - t.Error(err) - return - } + assert.NilError(t, err) if !bytes.Equal(data, cert) { t.Error("Expected key to match") diff --git a/clients/p2p/auth/stats_test.go b/clients/p2p/auth/stats_test.go index 432fb7aa..61edcee9 100644 --- a/clients/p2p/auth/stats_test.go +++ b/clients/p2p/auth/stats_test.go @@ -11,12 +11,14 @@ import ( ) func TestStats(t *testing.T) { + testDir, err := os.MkdirTemp("", "testdir") + assert.NilError(t, err) defer os.Remove(testDir) u := dream.New(dream.UniverseConfig{Name: t.Name()}) defer u.Stop() - err := u.StartWithConfig(&dream.Config{ + err = u.StartWithConfig(&dream.Config{ Services: map[string]commonIface.ServiceConfig{ "auth": {}, },