From 9a77de31dc9759708ce9c2d14ea7c0876c214e71 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Wed, 16 Sep 2026 00:53:52 +0200 Subject: config and engine can load with unsaved text --- internal/engine/engine_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'internal/engine/engine_test.go') diff --git a/internal/engine/engine_test.go b/internal/engine/engine_test.go index 7de2f76..b6b50fc 100644 --- a/internal/engine/engine_test.go +++ b/internal/engine/engine_test.go @@ -11,6 +11,7 @@ import ( "time" "krino/internal/cond" + "krino/internal/config" ) // sandbox gives a test its own HOME with no XDG overrides and returns it. @@ -296,3 +297,20 @@ func TestLoadRefusesBadPlaceholders(t *testing.T) { t.Errorf("valid placeholders refused: %v", errs) } } + +// TestEngineLoadWith: the engine compiles overridden text too, so unsaved +// rules are checked exactly as a run would read them (GUI design ยง1.3). +func TestEngineLoadWith(t *testing.T) { + h := sandbox(t) + os.MkdirAll(filepath.Join(h, "dl"), 0o755) + main := writeConfig(t, h, `(include "dl")`, map[string]string{"dl": "(path \"~/dl\")\n"}) + over := map[string][]byte{config.DirFile(main, "dl"): []byte("(path \"~/dl\")\n(rule \"r\" (when (bogus)) (move \"Out\"))\n")} + if _, errs := LoadWith(main, over); len(errs) == 0 { + t.Error("a mistake in the overridden directory file was not reported") + } + good := map[string][]byte{config.DirFile(main, "dl"): []byte("(path \"~/dl\")\n(rule \"r\" (move \"Out\"))\n")} + e, errs := LoadWith(main, good) + if len(errs) > 0 || len(e.Dirs) != 1 || len(e.Dirs[0].Rules) != 1 { + t.Errorf("overridden rules not compiled: %v", errs) + } +} -- cgit v1.3