Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestPeriodicalShareDomain(t *testing.T) {
|
|
s, _, source, actor := periodicalFixture(t)
|
|
r := httptest.NewRequest("GET", "http://localhost/v/blog/-/new", nil)
|
|
d, err := s.store.GetDomainByUUID(source)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err = s.store.CreateDomain(d.CampusUUID, "share-blog", "Share Blog", "blog.example.test", "local", "", "", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var target string
|
|
var id int64
|
|
if err = s.store.DB.QueryRow(`SELECT uuid,id FROM domains WHERE name='share-blog'`).Scan(&target, &id); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err = s.store.SetConfigInDomain(target, "home_layout", "blog"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err = s.store.DB.Exec(`INSERT INTO periodical_settings(domain_uuid,kind,enabled) VALUES(?,'blog',1)`, target); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err = s.store.SetPeriodicalProjection(context.Background(), id, actor, "blog", source, "/blog"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
targets := s.periodicalShareTargets(r, "blog", "/blog/2026/09/19/keyword")
|
|
if len(targets) != 1 || targets[0].URL != "https://blog.example.test/2026/09/19/keyword" || targets[0].Title != "Share Blog" {
|
|
t.Fatal(targets)
|
|
}
|
|
if targets := s.periodicalShareTargets(r, "blog", "/2026/09/19"); len(targets) != 0 {
|
|
t.Fatal("outside prefix", targets)
|
|
}
|
|
if _, err = s.store.DB.Exec(`UPDATE domains SET enabled=0 WHERE uuid=?`, target); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if targets := s.periodicalShareTargets(r, "blog", "/blog/2026/09/19"); len(targets) != 0 {
|
|
t.Fatal("disabled", targets)
|
|
}
|
|
}
|