commento/api/comment_approve_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

34 lines
898 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", false); 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
}
}