JSON CLI matching PHP ExportPosts/ImportPosts ships as HasCommands, and Posts toolbar actions reuse that logic behind access_import_export. Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package journal
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
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)
|
|
}
|
|
}
|