2018-05-27 22:40:42 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2018-07-25 02:34:42 +08:00
|
|
|
func TestCommentDomainPathGetBasics(t *testing.T) {
|
2018-05-27 22:40:42 +08:00
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
|
|
|
commentHex, _ := commentNew("temp-commenter-hex", "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC())
|
|
|
|
|
2018-07-25 02:34:42 +08:00
|
|
|
domain, path, err := commentDomainPathGet(commentHex)
|
2018-05-27 22:40:42 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("unexpected error getting domain by hex: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if domain != "example.com" {
|
2018-07-25 02:34:42 +08:00
|
|
|
t.Errorf("expected domain=example.com got domain=%s", domain)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if path != "/path.html" {
|
|
|
|
t.Errorf("expected path=/path.html got path=%s", path)
|
2018-05-27 22:40:42 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCommentDomainGetEmpty(t *testing.T) {
|
|
|
|
failTestOnError(t, setupTestEnv())
|
|
|
|
|
2018-07-25 02:34:42 +08:00
|
|
|
if _, _, err := commentDomainPathGet(""); err == nil {
|
2018-05-27 22:40:42 +08:00
|
|
|
t.Errorf("expected error not found getting domain with empty commentHex")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|