2018-05-27 22:40:42 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCommentApproveBasics(t *testing.T) {
|
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
2018-06-11 01:15:56 +08:00
|
|
|
commenterHex, _ := commenterNew("test@example.com", "Test", "undefined", "https://example.com/photo.jpg", "google", "")
|
2018-05-27 22:40:42 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-06-08 01:49:13 +08:00
|
|
|
if c, _, _ := commentList("anonymous", "example.com", "/path.html", true); c[0].State != "approved" {
|
2018-05-27 22:40:42 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|