43 lines
953 B
Go
43 lines
953 B
Go
package site
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRenderPlatformsShowsTheGuides(t *testing.T) {
|
|
root, err := filepath.Abs(filepath.Join("..", ".."))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
out := t.TempDir()
|
|
count, err := RenderPlatforms(root, out)
|
|
if err != nil {
|
|
t.Fatalf("RenderPlatforms: %v", err)
|
|
}
|
|
if count != 3 {
|
|
t.Fatalf("got %d guides, want 3", count)
|
|
}
|
|
raw, err := os.ReadFile(filepath.Join(out, "platforms", "index.html"))
|
|
if err != nil {
|
|
t.Fatalf("read page: %v", err)
|
|
}
|
|
page := strings.ToLower(string(raw))
|
|
for _, want := range []string{
|
|
"what the assistant reads",
|
|
"self-hosted git",
|
|
"personal knowledge base",
|
|
"knowledge graph over the notes",
|
|
"node_modules",
|
|
} {
|
|
if !strings.Contains(page, want) {
|
|
t.Errorf("page does not contain %q", want)
|
|
}
|
|
}
|
|
if _, err := os.Stat(filepath.Join(out, "platforms", "index.json")); err != nil {
|
|
t.Errorf("index.json missing: %v", err)
|
|
}
|
|
}
|