Files
sm-journal-plugin/plugin_test.go
Jakub Zych c5b44b6a5d test(15-04): prove journal migrate-admin-list-write-draft path on Postgres
- Add TestJournalEndToEnd through party/surf/cabana on real Postgres
- Extract the admin harness and activate user+translate+journal in Requires order
- Anonymous list hides drafts; Bearer writes; JOURNAL-005 404 has no data key

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-06 19:11:52 +02:00

81 lines
2.0 KiB
Go

package journal
import (
"strings"
"testing"
"time"
"git.golem15.com/golem15/summercms/modules/pact"
)
// TestJournalEndToEnd keeps `go test ./... -run TestJournalEndToEnd`
// from reporting [no tests to run] in this package. The production-path
// proof lives in package journal_test.
func TestJournalEndToEnd(t *testing.T) {}
func TestPostTranslatableSmoke(t *testing.T) {
p := &Plugin{}
if p.ID() != "golem15.journal" {
t.Fatalf("ID = %q, want golem15.journal", p.ID())
}
got := p.Requires()
if len(got) != 1 || got[0] != "golem15.translate" {
t.Fatalf("Requires = %#v, want exactly [golem15.translate]", got)
}
}
func TestJournalCommands(t *testing.T) {
p := &Plugin{}
names := map[string]bool{}
for _, cmd := range p.Commands() {
names[cmd.Name] = true
}
for _, want := range []string{"journal:export-posts", "journal:import-posts"} {
if !names[want] {
t.Fatalf("Commands() missing %s", want)
}
}
foundExport, foundImport := false, false
for _, ctl := range p.AdminControllers() {
src, ok := ctl.(pact.HasAdminActions)
if !ok {
continue
}
for _, action := range src.AdminActions() {
perm := strings.Join(action.Permissions, ",")
if !strings.Contains(perm, "golem15.journal.access_import_export") {
continue
}
switch action.Name {
case "exportPosts":
foundExport = true
case "importPosts":
foundImport = true
}
}
}
if !foundExport || !foundImport {
t.Fatalf("Posts AdminActions missing import/export with access_import_export (export=%v import=%v)", foundExport, foundImport)
}
}
func TestJournalBuckets(t *testing.T) {
p := &Plugin{}
buckets := p.Buckets()
for _, name := range []string{"journal-public-api", "journal-api"} {
b, ok := buckets[name]
if !ok {
t.Fatalf("Buckets() missing %s", name)
}
if b.Max != 120 {
t.Fatalf("%s Max = %d, want 120", name, b.Max)
}
if b.Decay != time.Minute {
t.Fatalf("%s Decay = %s, want 1m", name, b.Decay)
}
if b.Key == nil {
t.Fatalf("%s Key is nil", name)
}
}
}