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:

committed by
Adhityaa Chandrasekar

parent
0a03a2c6fc
commit
299649cea2
43
api/page_update_test.go
Normal file
43
api/page_update_test.go
Normal file
@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPageUpdateBasics(t *testing.T) {
|
||||
failTestOnError(t, setupTestEnv())
|
||||
|
||||
commenterHex, _ := commenterNew("test@example.com", "Test", "undefined", "https://example.com/photo.jpg", "google", "")
|
||||
|
||||
commentNew(commenterHex, "example.com", "/path.html", "root", "**foo**", "unapproved", time.Now().UTC())
|
||||
|
||||
p, _ := pageGet("example.com", "/path.html")
|
||||
if p.IsLocked != false {
|
||||
t.Errorf("expected IsLocked=false got %v", p.IsLocked)
|
||||
return
|
||||
}
|
||||
|
||||
p.IsLocked = true
|
||||
|
||||
if err := pageUpdate(p); err != nil {
|
||||
t.Errorf("unexpected error updating page: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
p, _ = pageGet("example.com", "/path.html")
|
||||
if p.IsLocked != true {
|
||||
t.Errorf("expected IsLocked=true got %v", p.IsLocked)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestPageUpdateEmpty(t *testing.T) {
|
||||
failTestOnError(t, setupTestEnv())
|
||||
|
||||
p := page{Domain: "", Path: "", IsLocked: false}
|
||||
if err := pageUpdate(p); err == nil {
|
||||
t.Errorf("expected error not found updating page with empty everything")
|
||||
return
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user