2018-05-27 22:40:42 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCommentDeleteBasics(t *testing.T) {
|
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
2021-02-28 15:14:10 +08:00
|
|
|
commenterHex := "temp-commenter-hex"
|
2021-02-28 15:09:31 +08:00
|
|
|
commentHex, _ := commentNew(commenterHex, "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC())
|
|
|
|
commentNew(commenterHex, "example.com", "/path.html", commentHex, "**bar**", "approved", time.Now().UTC())
|
2018-05-27 22:40:42 +08:00
|
|
|
|
2021-02-28 15:09:31 +08:00
|
|
|
if err := commentDelete(commentHex, commenterHex); err != nil {
|
2018-05-27 22:40:42 +08:00
|
|
|
t.Errorf("unexpected error deleting comment: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-02-28 15:09:31 +08:00
|
|
|
c, _, _ := commentList(commenterHex, "example.com", "/path.html", false)
|
2018-05-27 22:40:42 +08:00
|
|
|
|
|
|
|
if len(c) != 0 {
|
|
|
|
t.Errorf("expected no comments found %d comments", len(c))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCommentDeleteEmpty(t *testing.T) {
|
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
2021-02-28 15:09:31 +08:00
|
|
|
if err := commentDelete("", "test-commenter-hex"); err == nil {
|
2018-05-27 22:40:42 +08:00
|
|
|
t.Errorf("expected error deleting comment with empty commentHex")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|