api: fix test since change in commenter API

This commit is contained in:
Adhityaa 2018-06-07 23:16:17 +05:30
parent 8c4220dcd8
commit 5a7cffb317
2 changed files with 30 additions and 42 deletions

View File

@ -59,3 +59,33 @@ func TestCommenterGetBySessionEmpty(t *testing.T) {
return
}
}
func TestCommenterGetByName(t *testing.T) {
failTestOnError(t, setupTestEnv())
commenterHex, _ := commenterNew("test@example.com", "Test", "undefined", "https://example.com/photo.jpg", "google")
session, _ := commenterSessionNew()
commenterSessionUpdate(session, commenterHex)
c, err := commenterGetByEmail("google", "test@example.com")
if err != nil {
t.Errorf("unexpected error getting commenter by hex: %v", err)
return
}
if c.Name != "Test" {
t.Errorf("expected name=Test got name=%s", c.Name)
return
}
}
func TestCommenterGetByNameEmpty(t *testing.T) {
failTestOnError(t, setupTestEnv())
if _, err := commenterGetByEmail("", ""); err == nil {
t.Errorf("expected error not found getting commenter with empty everything")
return
}
}

View File

@ -1,42 +0,0 @@
package main
import (
"testing"
)
func TestCommenterIsProviderUserBasics(t *testing.T) {
failTestOnError(t, setupTestEnv())
commenterNew("test@example.com", "Test", "undefined", "https://example.com/photo.jpg", "google")
exists, err := commenterIsProviderUser("google", "test@example.com")
if err != nil {
t.Errorf("unexpected error checking if commenter is a provider user: %v", err)
return
}
if !exists {
t.Errorf("user expected to exist not found")
return
}
exists, err = commenterIsProviderUser("google", "test2@example.com")
if err != nil {
t.Errorf("unexpected error checking if commenter is a provider user: %v", err)
return
}
if exists {
t.Errorf("user expected to not exist not found")
return
}
}
func TestCommenterIsProviderUserEmpty(t *testing.T) {
failTestOnError(t, setupTestEnv())
if _, err := commenterIsProviderUser("google", ""); err == nil {
t.Errorf("expected error not found when checking for user with empty email")
return
}
}