2018-05-27 22:40:42 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestOwnerGetByEmailBasics(t *testing.T) {
|
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
|
|
|
ownerHex, _ := ownerNew("test@example.com", "Test", "hunter2")
|
|
|
|
|
|
|
|
o, err := ownerGetByEmail("test@example.com")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("unexpected error on ownerGetByEmail: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if o.OwnerHex != ownerHex {
|
|
|
|
t.Errorf("expected ownerHex=%s got ownerHex=%s", ownerHex, o.OwnerHex)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestOwnerGetByEmailDNE(t *testing.T) {
|
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
|
|
|
if _, err := ownerGetByEmail("invalid@example.com"); err == nil {
|
|
|
|
t.Errorf("expected error not found on ownerGetByEmail before creating an account")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 11:29:55 +08:00
|
|
|
func TestOwnerGetByOwnerTokenBasics(t *testing.T) {
|
2018-05-27 22:40:42 +08:00
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
|
|
|
ownerHex, _ := ownerNew("test@example.com", "Test", "hunter2")
|
|
|
|
|
2018-06-20 11:29:55 +08:00
|
|
|
ownerToken, _ := ownerLogin("test@example.com", "hunter2")
|
2018-05-27 22:40:42 +08:00
|
|
|
|
2018-06-20 11:29:55 +08:00
|
|
|
o, err := ownerGetByOwnerToken(ownerToken)
|
2018-05-27 22:40:42 +08:00
|
|
|
if err != nil {
|
2018-06-20 11:29:55 +08:00
|
|
|
t.Errorf("unexpected error on ownerGetByOwnerToken: %v", err)
|
2018-05-27 22:40:42 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if o.OwnerHex != ownerHex {
|
|
|
|
t.Errorf("expected ownerHex=%s got ownerHex=%s", ownerHex, o.OwnerHex)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 11:29:55 +08:00
|
|
|
func TestOwnerGetByOwnerTokenDNE(t *testing.T) {
|
2018-05-27 22:40:42 +08:00
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
2018-06-20 11:29:55 +08:00
|
|
|
if _, err := ownerGetByOwnerToken("does-not-exist"); err == nil {
|
|
|
|
t.Errorf("expected error not found on ownerGetByOwnerToken before creating an account")
|
2018-05-27 22:40:42 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|