tests: Test .config
stays clean with XDG_CONFIG_HOME set
This commit is contained in:
parent
1765711b68
commit
bf07581497
|
@ -1,5 +1,31 @@
|
|||
source common.sh
|
||||
|
||||
# Isolate the home for this test.
|
||||
# Other tests (e.g. flake registry tests) could be writing to $HOME in parallel.
|
||||
export HOME=$TEST_ROOT/userhome
|
||||
|
||||
# Test that using XDG_CONFIG_HOME works
|
||||
# Assert the config folder didn't exist initially.
|
||||
[ ! -e "$HOME/.config" ]
|
||||
# Without XDG_CONFIG_HOME, creates $HOME/.config
|
||||
unset XDG_CONFIG_HOME
|
||||
# Run against the nix registry to create the config dir
|
||||
# (Tip: this relies on removing non-existent entries being a no-op!)
|
||||
nix registry remove userhome-without-xdg
|
||||
# Verifies it created it
|
||||
[ -e "$HOME/.config" ]
|
||||
# Remove the directory it created
|
||||
rm -rf "$HOME/.config"
|
||||
# Run the same test, but with XDG_CONFIG_HOME
|
||||
export XDG_CONFIG_HOME=$TEST_ROOT/confighome
|
||||
# Assert the XDG_CONFIG_HOME/nix path does not exist yet.
|
||||
[ ! -e "$TEST_ROOT/confighome/nix" ]
|
||||
nix registry remove userhome-with-xdg
|
||||
# Verifies the confighome path has been created
|
||||
[ -e "$TEST_ROOT/confighome/nix" ]
|
||||
# Assert the .config folder hasn't been created.
|
||||
[ ! -e "$HOME/.config" ]
|
||||
|
||||
# Test that files are loaded from XDG by default
|
||||
export XDG_CONFIG_HOME=$TEST_ROOT/confighome
|
||||
export XDG_CONFIG_DIRS=$TEST_ROOT/dir1:$TEST_ROOT/dir2
|
||||
|
|
Loading…
Reference in a new issue