summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/target_policy_test.lua24
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")