aboutsummaryrefslogtreecommitdiff
path: root/tests/config.sh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-10-05 12:12:18 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-12-01 12:06:43 -0500
commit30dcc19d1f30fc203be460134c4578509cce704f (patch)
tree6cc32609b9984a2c4d5ecc0cac5cf30609e208b9 /tests/config.sh
parent72425212657d795dc215b334b7c8c8cd36d06b72 (diff)
Put functional tests in `tests/functional`
I think it is bad for these reasons when `tests/` contains a mix of functional and integration tests - Concepts is harder to understand, the documentation makes a good unit vs functional vs integration distinction, but when the integration tests are just two subdirs within `tests/` this is not clear. - Source filtering in the `flake.nix` is more complex. We need to filter out some of the dirs from `tests/`, rather than simply pick the dirs we want and take all of them. This is a good sign the structure of what we are trying to do is not matching the structure of the files. With this change we have a clean: ```shell-session $ git show 'HEAD:tests' tree HEAD:tests functional/ installer/ nixos/ ``` (cherry picked from commit 68c81c737571794f7246db53fb4774e94fcf4b7e)
Diffstat (limited to 'tests/config.sh')
-rw-r--r--tests/config.sh58
1 files changed, 0 insertions, 58 deletions
diff --git a/tests/config.sh b/tests/config.sh
deleted file mode 100644
index 723f575ed..000000000
--- a/tests/config.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-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
-files=$(nix-build --verbose --version | grep "User config" | cut -d ':' -f2- | xargs)
-[[ $files == "$TEST_ROOT/confighome/nix/nix.conf:$TEST_ROOT/dir1/nix/nix.conf:$TEST_ROOT/dir2/nix/nix.conf" ]]
-
-# Test that setting NIX_USER_CONF_FILES overrides all the default user config files
-export NIX_USER_CONF_FILES=$TEST_ROOT/file1.conf:$TEST_ROOT/file2.conf
-files=$(nix-build --verbose --version | grep "User config" | cut -d ':' -f2- | xargs)
-[[ $files == "$TEST_ROOT/file1.conf:$TEST_ROOT/file2.conf" ]]
-
-# Test that it's possible to load the config from a custom location
-here=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
-export NIX_USER_CONF_FILES=$here/config/nix-with-substituters.conf
-var=$(nix show-config | grep '^substituters =' | cut -d '=' -f 2 | xargs)
-[[ $var == https://example.com ]]
-
-# Test that it's possible to load config from the environment
-prev=$(nix show-config | grep '^cores' | cut -d '=' -f 2 | xargs)
-export NIX_CONFIG="cores = 4242"$'\n'"experimental-features = nix-command flakes"
-exp_cores=$(nix show-config | grep '^cores' | cut -d '=' -f 2 | xargs)
-exp_features=$(nix show-config | grep '^experimental-features' | cut -d '=' -f 2 | xargs)
-[[ $prev != $exp_cores ]]
-[[ $exp_cores == "4242" ]]
-[[ $exp_features == "flakes nix-command" ]]
-
-# Test that it's possible to retrieve a single setting's value
-val=$(nix show-config | grep '^warn-dirty' | cut -d '=' -f 2 | xargs)
-val2=$(nix show-config warn-dirty)
-[[ $val == $val2 ]]