commento/api/comment_approve_test.go
Adhityaa 2020405e8b frontend, api: allow custom emails as commenters
I'm really sorry this came out as one huge commit, but I'm afraid
I can't split this up.

Closes https://gitlab.com/commento/commento-ce/issues/9
2018-06-10 22:58:54 +05:30

34 lines
901 B
Go

package main
import (
"testing"
"time"
)
func TestCommentApproveBasics(t *testing.T) {
failTestOnError(t, setupTestEnv())
commenterHex, _ := commenterNew("test@example.com", "Test", "undefined", "https://example.com/photo.jpg", "google", "")
commentHex, _ := commentNew(commenterHex, "example.com", "/path.html", "root", "**foo**", "unapproved", time.Now().UTC())
if err := commentApprove(commentHex); err != nil {
t.Errorf("unexpected error approving comment: %v", err)
return
}
if c, _, _ := commentList("anonymous", "example.com", "/path.html", true); c[0].State != "approved" {
t.Errorf("expected state = approved got state = %s", c[0].State)
return
}
}
func TestCommentApproveEmpty(t *testing.T) {
failTestOnError(t, setupTestEnv())
if err := commentApprove(""); err == nil {
t.Errorf("expected error not found approving comment with empty commentHex")
return
}
}