1
mirror of https://gitlab.com/commento/commento.git synced 2025-06-29 22:56:37 -04:00

api,db: add page attributes and thread locking

This commit is contained in:
Adhityaa
2018-07-05 10:36:52 +05:30
committed by Adhityaa Chandrasekar
parent 0a03a2c6fc
commit 299649cea2
16 changed files with 427 additions and 4 deletions

43
api/page_new_test.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"testing"
)
func TestPageNewBasics(t *testing.T) {
failTestOnError(t, setupTestEnv())
if err := pageNew("example.com", "/path.html"); err != nil {
t.Errorf("unexpected error creating page: %v", err)
return
}
}
func TestPageNewEmpty(t *testing.T) {
failTestOnError(t, setupTestEnv())
if err := pageNew("example.com", ""); err != nil {
t.Errorf("unexpected error creating page with empty path: %v", err)
return
}
if err := pageNew("", "/path.html"); err == nil {
t.Errorf("expected error not found creating page with empty domain")
return
}
}
func TestPageNewUnique(t *testing.T) {
failTestOnError(t, setupTestEnv())
if err := pageNew("example.com", "/path.html"); err != nil {
t.Errorf("unexpected error creating page: %v", err)
return
}
// no error should be returned when trying to duplicate insert
if err := pageNew("example.com", "/path.html"); err != nil {
t.Errorf("unexpected error creating same page twice: %v", err)
return
}
}