mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-29 22:56:37 -04:00
api: Add go files
I know this is a huge commit, but I can't be bothered to check this in part by part.
This commit is contained in:
43
api/comment_ownership_verify_test.go
Normal file
43
api/comment_ownership_verify_test.go
Normal file
@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCommentOwnershipVerifyBasics(t *testing.T) {
|
||||
failTestOnError(t, setupTestEnv())
|
||||
|
||||
commentHex, _ := commentNew("temp-commenter-hex", "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC())
|
||||
|
||||
isOwner, err := commentOwnershipVerify("temp-commenter-hex", commentHex)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error verifying ownership: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if !isOwner {
|
||||
t.Errorf("expected to be owner of comment")
|
||||
return
|
||||
}
|
||||
|
||||
isOwner, err = commentOwnershipVerify("another-commenter-hex", commentHex)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error verifying ownership: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if isOwner {
|
||||
t.Errorf("unexpected owner of comment not created by another-commenter-hex")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommentOwnershipVerifyEmpty(t *testing.T) {
|
||||
failTestOnError(t, setupTestEnv())
|
||||
|
||||
if _, err := commentOwnershipVerify("temp-commenter-hex", ""); err == nil {
|
||||
t.Errorf("expected error not founding verifying ownership with empty commentHex")
|
||||
return
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user