From 5a7cffb317887631906ab261c54d1677b75c66d5 Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Thu, 7 Jun 2018 23:16:17 +0530 Subject: [PATCH] api: fix test since change in commenter API --- api/commenter_get_test.go | 30 ++++++++++++++++++++++++++++ api/commenter_test.go | 42 --------------------------------------- 2 files changed, 30 insertions(+), 42 deletions(-) delete mode 100644 api/commenter_test.go diff --git a/api/commenter_get_test.go b/api/commenter_get_test.go index 5e223dd..3f11951 100644 --- a/api/commenter_get_test.go +++ b/api/commenter_get_test.go @@ -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 + } +} diff --git a/api/commenter_test.go b/api/commenter_test.go deleted file mode 100644 index c4aa047..0000000 --- a/api/commenter_test.go +++ /dev/null @@ -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 - } -}