Skip to content

Commit

Permalink
Fixed user password hash invalid instead of nil as error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed Jul 8, 2018
1 parent 1a9fd29 commit c5e808e
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,15 @@ 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) {
err := store.Init()
if err != nil {
t.Fatal(err)
}
defer os.Remove("data/gaia.db")

u := &gaia.User{}
u.Username = "testuser"
Expand All @@ -77,19 +73,14 @@ 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) {
err := store.Init()
if err != nil {
t.Fatal(err)
}
defer os.Remove("data/gaia.db")

u := &gaia.User{}
u.Username = "testuser"
Expand All @@ -99,19 +90,14 @@ 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) {
err := store.Init()
if err != nil {
t.Fatal(err)
}
defer os.Remove("data/gaia.db")

u := &gaia.User{}
u.Username = "testuser"
Expand Down Expand Up @@ -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)
}
}

0 comments on commit c5e808e

Please sign in to comment.