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, the rebuild job (kind golem15.sitemap.rebuild, // three attempts) and the IndexNow job (golem15.sitemap.indexnow, five). 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) != 2 { 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) } info, ok = conga.Describe(jobs[1]) if !ok || info.Kind != classes.IndexNowKind || info.MaxAttempts != 5 { t.Fatalf("job = %+v %v", info, ok) } }