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.
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestExportHandbook(t *testing.T) {
|
|
dest := t.TempDir()
|
|
if err := export("../../docs/design/ja", dest); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
b, err := os.ReadFile(filepath.Join(dest, "manifest.json"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var manifest []entry
|
|
if err := json.Unmarshal(b, &manifest); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(manifest) != 23 {
|
|
t.Fatalf("got %d chapters", len(manifest))
|
|
}
|
|
for _, e := range manifest {
|
|
b, err := os.ReadFile(filepath.Join(dest, e.File))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if e.Language != "ja" || e.HTMLSHA256 != digest(b) || !strings.Contains(string(b), "<h1>") {
|
|
t.Fatalf("invalid payload: %s", e.Chapter)
|
|
}
|
|
if err := validateLinks(string(b)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if e.Chapter == "address-storage" && !strings.Contains(string(b), "<table>") {
|
|
t.Fatal("Markdown tables lost")
|
|
}
|
|
}
|
|
if err := export("../../docs/design/ja", dest); err == nil {
|
|
t.Fatal("must not overwrite staging artifacts")
|
|
}
|
|
}
|
|
|
|
func TestUnknownLink(t *testing.T) {
|
|
if validateLinks(`<a href="/lab/pageswiki-dev/missing">x</a>`) == nil {
|
|
t.Fatal("broken chapter link accepted")
|
|
}
|
|
}
|