commento/api/owner_new_test.go
Adhityaa a090770b73 api: Add go files
I know this is a huge commit, but I can't be bothered to check
this in part by part.
2018-05-27 23:40:46 +05:30

43 lines
1018 B
Go

package main
import (
"testing"
)
func TestOwnerNewBasics(t *testing.T) {
failTestOnError(t, setupTestEnv())
if _, err := ownerNew("test@example.com", "Test", "hunter2"); err != nil {
t.Errorf("unexpected error when creating new owner: %v", err)
return
}
}
func TestOwnerNewClash(t *testing.T) {
failTestOnError(t, setupTestEnv())
if _, err := ownerNew("test@example.com", "Test", "hunter2"); err != nil {
t.Errorf("unexpected error when creating new owner: %v", err)
return
}
if _, err := ownerNew("test@example.com", "Test", "hunter2"); err == nil {
t.Errorf("expected error not found when creating with clashing email")
return
}
}
func TestOwnerNewEmpty(t *testing.T) {
failTestOnError(t, setupTestEnv())
if _, err := ownerNew("test@example.com", "", "hunter2"); err == nil {
t.Errorf("expected error not found when passing empty name")
return
}
if _, err := ownerNew("", "", ""); err == nil {
t.Errorf("expected error not found when passing empty everything")
return
}
}