From c5e808e34988689b85d846f0755132f7b525ae49 Mon Sep 17 00:00:00 2001 From: Gergely Brautigam Date: Sun, 8 Jul 2018 17:58:00 +0200 Subject: [PATCH] Fixed user password hash invalid instead of nil as error. --- store/store_test.go | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/store/store_test.go b/store/store_test.go index 710d7b3a..9ae6a345 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -39,12 +39,7 @@ func TestInit(t *testing.T) { if err != nil { t.Fatal(err) } - - // cleanup - err = os.Remove("data/gaia.db") - if err != nil { - t.Fatal(err) - } + defer os.Remove("data/gaia.db") } func TestUserGet(t *testing.T) { @@ -52,6 +47,7 @@ func TestUserGet(t *testing.T) { if err != nil { t.Fatal(err) } + defer os.Remove("data/gaia.db") u := &gaia.User{} u.Username = "testuser" @@ -77,12 +73,6 @@ func TestUserGet(t *testing.T) { if user == nil { t.Fatalf("Expected user %v. Got nil.", u.Username) } - - // cleanup - err = os.Remove("data/gaia.db") - if err != nil { - t.Fatal(err) - } } func TestUserPut(t *testing.T) { @@ -90,6 +80,7 @@ func TestUserPut(t *testing.T) { if err != nil { t.Fatal(err) } + defer os.Remove("data/gaia.db") u := &gaia.User{} u.Username = "testuser" @@ -99,12 +90,6 @@ func TestUserPut(t *testing.T) { if err != nil { t.Fatal(err) } - - // cleanup - err = os.Remove("data/gaia.db") - if err != nil { - t.Fatal(err) - } } func TestUserAuth(t *testing.T) { @@ -112,6 +97,7 @@ func TestUserAuth(t *testing.T) { if err != nil { t.Fatal(err) } + defer os.Remove("data/gaia.db") u := &gaia.User{} u.Username = "testuser" @@ -149,16 +135,10 @@ func TestUserAuth(t *testing.T) { u.Username = "testuser" u.Password = "wrongpassword" r, err = store.UserAuth(u, true) - if err != nil { + if err == nil { t.Fatal(err) } if r != nil { t.Fatalf("Expected nil object here. User shouldnt be valid") } - - // cleanup - err = os.Remove("data/gaia.db") - if err != nil { - t.Fatal(err) - } }