The project is now norn: .loom/ is .norn/, loomctl is nornctl (NORNCTL_* env vars, ~/.config/nornctl), and the Gitea org is norn. Event logs moved with the directory but their text is unchanged — they are a record of what was decided at the time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
1.8 KiB
Go
74 lines
1.8 KiB
Go
package orient
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.hypertheory-labs.dev/norn/norn-cli/internal/lock"
|
|
)
|
|
|
|
// A generated file that churns produces diffs nobody reads, and the diff is most
|
|
// of the value.
|
|
func TestGenerateIsDeterministic(t *testing.T) {
|
|
root := t.TempDir()
|
|
locks, err := lock.LoadFile(lock.Path(root))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// Inserted out of order on purpose: the output must not depend on it.
|
|
for _, r := range []lock.Record{
|
|
{Path: "h/o/zeta/z.md", URL: "https://h/z", ETag: `"3"`},
|
|
{Path: "h/o/alpha/a.md", URL: "https://h/a", ETag: `"1"`},
|
|
{Path: "h/o/mid/m.md", URL: "https://h/m", ETag: `"2"`},
|
|
} {
|
|
locks.Put(r)
|
|
}
|
|
if err := locks.Save(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
var first string
|
|
for i := 0; i < 3; i++ {
|
|
dest, err := Generate(root, filepath.Join(root, "out.md"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
b, err := os.ReadFile(dest)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if i == 0 {
|
|
first = string(b)
|
|
continue
|
|
}
|
|
if string(b) != first {
|
|
t.Fatal("output changed between runs")
|
|
}
|
|
}
|
|
if a, z := strings.Index(first, "alpha"), strings.Index(first, "zeta"); a > z {
|
|
t.Error("entries are not ordered by path")
|
|
}
|
|
if strings.Contains(first, "publishes") {
|
|
t.Error("claimed the repository publishes with no .norn/published")
|
|
}
|
|
}
|
|
|
|
func TestSaysWhenNothingRecordsADependency(t *testing.T) {
|
|
root := t.TempDir()
|
|
locks, _ := lock.LoadFile(lock.Path(root))
|
|
locks.Put(lock.Record{Path: "h/o/r/doc.md", URL: "https://h/doc", ETag: `"1"`})
|
|
if err := locks.Save(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
dest, err := Generate(root, filepath.Join(root, "out.md"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
b, _ := os.ReadFile(dest)
|
|
if !strings.Contains(string(b), "nothing recorded") {
|
|
t.Error("a document with no .usages.md should say so — it is a finding, not an omission")
|
|
}
|
|
}
|