test(guards): cover the cascade's subcategory -> category -> master order

13 cases on invented variable names, so nothing ambient can perturb them:
default-on, explicit truthy/falsy, unrecognized-defers, subcategory
overriding the category in both directions, and the four cases that
together pin the master as an off switch only.
This commit is contained in:
2026-09-07 20:07:37 -04:00
parent a8d564803b
commit 2b1e99ab47
+67
View File
@@ -71,4 +71,71 @@ __fish_variable_check __probe_v
check "multi-element list -> 3" 3 $status check "multi-element list -> 3" 3 $status
set -e __probe_v set -e __probe_v
section "cascade: category only"
# Invented variable names the real config can never set, so nothing ambient can
# perturb these -- only the C5 and master cases below need real names.
set -e __fish_config_opinionated __probe_cat __probe_cat_sub
__fish_config_op_cascade __probe_cat
check "all unset -> enabled" 0 $status
set -g __probe_cat 0
__fish_config_op_cascade __probe_cat
check "category falsy -> disabled" 1 $status
set -g __probe_cat 1
__fish_config_op_cascade __probe_cat
check "category truthy -> enabled" 0 $status
set -g __probe_cat garbage
__fish_config_op_cascade __probe_cat
check "category unrecognized defers to master -> enabled" 0 $status
set -e __probe_cat
section "cascade: subcategory beats category"
set -g __probe_cat 0
set -g __probe_cat_sub 1
__fish_config_op_cascade __probe_cat __probe_cat_sub
check "sub on, category off -> enabled" 0 $status
set -g __probe_cat 1
set -g __probe_cat_sub 0
__fish_config_op_cascade __probe_cat __probe_cat_sub
check "sub off, category on -> disabled" 1 $status
set -e __probe_cat_sub
set -g __probe_cat 0
__fish_config_op_cascade __probe_cat __probe_cat_sub
check "sub unset, category off -> disabled" 1 $status
set -g __probe_cat_sub garbage
__fish_config_op_cascade __probe_cat __probe_cat_sub
check "sub unrecognized defers, category off -> disabled" 1 $status
set -e __probe_cat __probe_cat_sub
__fish_config_op_cascade __probe_cat ""
check "empty subcategory argument -> category-only chain" 0 $status
section "cascade: the master is an off switch only"
set -g __fish_config_opinionated 0
__fish_config_op_cascade __probe_cat
check "master off, category unset -> disabled" 1 $status
set -g __probe_cat 1
__fish_config_op_cascade __probe_cat
check "master off, category on -> enabled" 0 $status
set -e __probe_cat
set -g __fish_config_opinionated 1
__fish_config_op_cascade __probe_cat
check "master on, category unset -> enabled" 0 $status
set -g __fish_config_opinionated garbage
__fish_config_op_cascade __probe_cat
check "master unrecognized, category unset -> enabled" 0 $status
set -e __fish_config_opinionated
report report