From 8a05e61feb2a8b7c73c6f4c8f11c5a076c43170b Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Wed, 2 Oct 2019 17:02:16 +0300 Subject: [PATCH] *: fix auth tests - don't leave repo dirty --- home/auth_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/home/auth_test.go b/home/auth_test.go index 61bf4b23..abb6dfc4 100644 --- a/home/auth_test.go +++ b/home/auth_test.go @@ -3,6 +3,7 @@ package home import ( "encoding/hex" "os" + "path/filepath" "testing" "time" @@ -10,13 +11,17 @@ import ( ) func TestAuth(t *testing.T) { - fn := "./sessions.db" + config.ourWorkingDir = "." + fn := filepath.Join(config.getDataDir(), "sessions.db") + + _ = os.RemoveAll(config.getDataDir()) + defer func() { _ = os.RemoveAll(config.getDataDir()) }() + users := []User{ User{Name: "name", PasswordHash: "$2y$05$..vyzAECIhJPfaQiOK17IukcQnqEgKJHy0iETyYqxn3YXJl8yZuo2"}, } - os.Remove(fn) - config.ourWorkingDir = "." + os.MkdirAll(config.getDataDir(), 0755) a := InitAuth(fn, users) assert.True(t, a.CheckSession("notfound") == -1)