diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-05 14:05:45 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-05 14:05:45 +0200 |
| commit | e503ba1ff340e1887dc74c36064804c72b514980 (patch) | |
| tree | b3633dbfbdd99e169ab4b3ac9fbff8d41491d7a9 | |
| parent | 83cba1f85b8d555b74f5eea4fd616d609bafddac (diff) | |
Add entry classification fixtures
| -rw-r--r-- | tests/target_policy_test.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/target_policy_test.lua b/tests/target_policy_test.lua index 4ce9b98..7b5635e 100644 --- a/tests/target_policy_test.lua +++ b/tests/target_policy_test.lua @@ -71,4 +71,28 @@ for _, case in ipairs(decisions) do assert_equal(sync_calls, calls_before, case.label .. " host call count") end +local classification_fixtures = { + { + label = "usable directory symbolic link", + cha = { is_dir = true, is_link = true, is_orphan = false }, + expected = { directory = "enter", file = "none", either = "enter" }, + }, + { + label = "broken symbolic link with is_dir=false", + cha = { is_dir = false, is_link = true, is_orphan = true }, + expected = { directory = "none", file = "open-hovered", either = "open-hovered" }, + }, +} + +for _, fixture in ipairs(classification_fixtures) do + assert_equal(fixture.cha.is_link, true, fixture.label .. " link status") + for _, mode in ipairs({ "directory", "file", "either" }) do + local calls_before = sync_calls + local result = pack_values(target_policy(mode, fixture.cha.is_dir)) + assert_equal(result.n, 1, fixture.label .. " " .. mode .. " return count") + assert_equal(result[1], fixture.expected[mode], fixture.label .. " " .. mode .. " decision") + assert_equal(sync_calls, calls_before, fixture.label .. " " .. mode .. " host call count") + end +end + print("target policy checks passed") |