Skip to content

Commit

Permalink
Improve store tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ecanuto committed Aug 15, 2020
1 parent 68098c4 commit 4cbd42f
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions pkg/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,56 @@ func TestStoreDefaultDriver(t *testing.T) {
}
defer store.Close()
}

func TestStoreAuthEmpty(t *testing.T) {
store, err := Default()
if err != nil {
t.Errorf("Error \"%v\".", err)
}
defer store.Close()

expect := false
result := store.Auth("")
if result != expect {
t.Errorf("Expected %v and got %v.", expect, result)
}
}

func TestStoreAuth(t *testing.T) {
store, err := Default()
if err != nil {
t.Errorf("Error \"%v\".", err)
}
defer store.Close()

token := "qwert"
store.AuthToken = token
expect := true
result := store.Auth(token)
if result != expect {
t.Errorf("Expected %v and got %v.", expect, result)
}
}

func TestStorePutGet(t *testing.T) {
store, err := Default()
if err != nil {
t.Errorf("Error \"%v\".", err)
}
defer store.Close()

url := "https://github.com/noverde/pequi"
res, err := store.Put(url)
if err != nil {
t.Errorf("Error \"%v\".", err)
}

val, err := store.Get(res)
if err != nil {
t.Errorf("Error \"%v\".", err)
}
if val != url {
t.Errorf("Expected \"%v\" and got \"%v\".", val, url)
}

}

0 comments on commit 4cbd42f

Please sign in to comment.