comment_count_test.go: use array of strings

This commit is contained in:
Adhityaa Chandrasekar 2019-03-10 09:23:34 -04:00
parent a2c8a73d3e
commit 5f1d46c7b2

View File

@ -14,14 +14,14 @@ func TestCommentCountBasics(t *testing.T) {
commentNew(commenterHex, "example.com", "/path.html", "root", "**bar**", "approved", time.Now().UTC())
commentNew(commenterHex, "example.com", "/path.html", "root", "**baz**", "unapproved", time.Now().UTC())
count, err := commentCount("example.com", "/path.html")
counts, err := commentCount("example.com", []string{"/path.html"})
if err != nil {
t.Errorf("unexpected error counting comments: %v", err)
return
}
if count != 2 {
t.Errorf("expected count=2 got count=%d", count)
if counts["/path.html"] != 2 {
t.Errorf("expected count=2 got count=%d", counts["/path.html"])
return
}
}
@ -29,25 +29,25 @@ func TestCommentCountBasics(t *testing.T) {
func TestCommentCountNewPage(t *testing.T) {
failTestOnError(t, setupTestEnv())
count, err := commentCount("example.com", "/path.html")
counts, err := commentCount("example.com", []string{"/path.html"})
if err != nil {
t.Errorf("unexpected error counting comments: %v", err)
return
}
if count != 0 {
t.Errorf("expected count=0 got count=%d", count)
if counts["/path.html"] != 0 {
t.Errorf("expected count=0 got count=%d", counts["/path.html"])
return
}
}
func TestCommentCountEmpty(t *testing.T) {
if _, err := commentCount("example.com", ""); err != nil {
if _, err := commentCount("example.com", []string{""}); err != nil {
t.Errorf("unexpected error counting comments on empty path: %v", err)
return
}
if _, err := commentCount("", ""); err == nil {
if _, err := commentCount("", []string{""}); err == nil {
t.Errorf("expected error not found counting comments with empty everything")
return
}