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>
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package external
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.hypertheory-labs.dev/norn/norn-cli/internal/lock"
|
|
)
|
|
|
|
// apply used to write the staged record verbatim, and a staged record carried no
|
|
// visibility — so every update silently dropped a column the lock header says is
|
|
// recorded because access is checked once and the copy is durable.
|
|
func TestApplyDoesNotDropVisibility(t *testing.T) {
|
|
root := t.TempDir()
|
|
|
|
locks, _ := lock.LoadFile(lock.Path(root))
|
|
locks.Put(lock.Record{Path: "h/o/r/d.md", URL: "https://h/d", ETag: `"old"`, Visibility: lock.NotPublic})
|
|
if err := locks.Save(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// A polad staged by a build that did not record visibility.
|
|
if err := stage(root, "h/o/r/d.md", []byte("new"), lock.Record{
|
|
Path: "h/o/r/d.md", URL: "https://h/d", ETag: `"new"`,
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := Apply(root, nil, io.Discard); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
after, _ := lock.Load(root)
|
|
got, ok := after.Get("h/o/r/d.md")
|
|
if !ok {
|
|
t.Fatal("record vanished")
|
|
}
|
|
if got.ETag != `"new"` {
|
|
t.Errorf("etag = %q, want the staged one", got.ETag)
|
|
}
|
|
if got.Visibility != lock.NotPublic {
|
|
t.Errorf("visibility = %q, want it preserved as %q", got.Visibility, lock.NotPublic)
|
|
}
|
|
if b, err := os.ReadFile(filepath.Join(root, lock.Dir, "h/o/r/d.md")); err != nil || string(b) != "new" {
|
|
t.Errorf("applied content = %q, %v", b, err)
|
|
}
|
|
}
|