- RecordSaved with a change outside golem15.sitemap.lastmod_ignore moves the lastmod of the record's rows (only the changed locale's for a translated change); a no-op save, an ignored change or a rebuild does not - RecordDeleted takes the record's rows out of the files at once - record events queue one rebuild per golem15.sitemap.rebuild_delay_seconds (rebuild_pending_until, P33-12); the job clears it when it starts - sitemap:rebuild [--queue], scheduled nightly at 03:00 (pact.HasSchedule)
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package sitemap
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.golem15.com/golem15/sm-sitemap-plugin/classes"
|
|
"git.golem15.com/golem15/summercms/modules/bonfire"
|
|
"git.golem15.com/golem15/summercms/modules/conga"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
// TestCommandsDocumented logs every console command whose help lacks a
|
|
// description, long help, examples or an option description
|
|
// (bonfire.CheckDocs). It only warns: the framework's own coverage test
|
|
// fails on a gap, plugin repositories report it.
|
|
func TestCommandsDocumented(t *testing.T) {
|
|
commands := (&Plugin{}).Commands()
|
|
if len(commands) == 0 {
|
|
t.Fatal("the plugin declares no commands")
|
|
}
|
|
for _, problem := range bonfire.CheckDocs(commands) {
|
|
t.Logf("%s", problem)
|
|
}
|
|
}
|
|
|
|
// TestScheduleAndJobs pins the nightly sitemap:rebuild at 03:00, which must
|
|
// name a registered command, and the rebuild job (kind
|
|
// golem15.sitemap.rebuild, three attempts).
|
|
func TestScheduleAndJobs(t *testing.T) {
|
|
p := &Plugin{}
|
|
entries := p.Schedule()
|
|
if len(entries) != 1 || entries[0].Command != "sitemap:rebuild" || entries[0].Cadence != pact.DailyAt(3, 0) {
|
|
t.Fatalf("schedule = %+v", entries)
|
|
}
|
|
found := false
|
|
for _, c := range p.Commands() {
|
|
found = found || c.Name == entries[0].Command
|
|
}
|
|
if !found {
|
|
t.Fatal("the scheduled command is not registered")
|
|
}
|
|
jobs := p.Jobs()
|
|
if len(jobs) != 1 {
|
|
t.Fatalf("%d jobs", len(jobs))
|
|
}
|
|
info, ok := conga.Describe(jobs[0])
|
|
if !ok || info.Kind != classes.RebuildKind || info.MaxAttempts != 3 {
|
|
t.Fatalf("job = %+v %v", info, ok)
|
|
}
|
|
}
|