diff --git a/tests/on-device/config-default.bats b/tests/on-device/config-default.bats index 5565078..ebb54e8 100644 --- a/tests/on-device/config-default.bats +++ b/tests/on-device/config-default.bats @@ -4,4 +4,7 @@ load lib @test 'default config can be switched into' { switch_to_default_config + + assert_command nix-on-droid nix-shell bash vi find + assert_no_command dash xonsh zsh } diff --git a/tests/on-device/config-flake-h-m.bats b/tests/on-device/config-flake-h-m.bats index 1085488..2be3e49 100644 --- a/tests/on-device/config-flake-h-m.bats +++ b/tests/on-device/config-flake-h-m.bats @@ -3,8 +3,7 @@ load lib @test 'flake + h-m + #134 overlays case work' { - # start from a known baseline - switch_to_default_config + # assertions to verify initial state is as expected assert_command vi assert_no_command dash zsh diff --git a/tests/on-device/config-flake.bats b/tests/on-device/config-flake.bats index bdb6b4c..08c1107 100644 --- a/tests/on-device/config-flake.bats +++ b/tests/on-device/config-flake.bats @@ -3,11 +3,11 @@ load lib @test 'flake example works' { - # start from a known baseline - switch_to_default_config + # assertions to verify initial state is as expected assert_command vi - assert_no_command dash unzip + assert_no_command unzip + # set up / build / activate the configuration nix-shell -p gnused --run \ "sed \ -e s/vim/nano/ \ @@ -39,5 +39,5 @@ load lib rm -f ~/.config/nix/nix.conf ~/.config/nixpkgs/flake.nix switch_to_default_config assert_command vi - assert_no_command dash unzip + assert_no_command unzip } diff --git a/tests/on-device/config-h-m.bats b/tests/on-device/config-h-m.bats index d76e393..2380a0e 100644 --- a/tests/on-device/config-h-m.bats +++ b/tests/on-device/config-h-m.bats @@ -2,13 +2,17 @@ load lib +teardown() { + rm -f ~/.config/example +} + @test 'using home-manager works' { - # start from a known baseline - switch_to_default_config + # assertions to verify initial state is as expected assert_command vi assert_no_command dash - ! [[ -e ~/.config/example ]] + [[ ! -e ~/.config/example ]] + # set up / build / activate the configuration nix-channel --add https://github.com/rycee/home-manager/archive/release-21.11.tar.gz home-manager nix-channel --update cp "$ON_DEVICE_TESTS_DIR/config-h-m.nix" ~/.config/nixpkgs/nix-on-droid.nix @@ -30,5 +34,11 @@ load lib [[ "$output" == success ]] [[ "$status" == 42 ]] + # check that reverting works too switch_to_default_config + assert_command vi + assert_no_command unzip + + # file will be still present because home-manager needs to be set up to remove old links + [[ -e ~/.config/example ]] } diff --git a/tests/on-device/lib.bash b/tests/on-device/lib.bash index f22ad35..f597be7 100644 --- a/tests/on-device/lib.bash +++ b/tests/on-device/lib.bash @@ -26,6 +26,9 @@ setup() { # restore to pre-testing generation before the start of each test $DEFAULT_ACTIVATE_SCRIPT + + # build and activate the version of nix-on-droid that is subject to test + switch_to_default_config } assert_command() { @@ -47,7 +50,4 @@ switch_to_default_config() { cat "$CHANNEL_DIR/modules/environment/login/nix-on-droid.nix.default" \ > ~/.config/nixpkgs/nix-on-droid.nix nix-on-droid switch - - assert_command nix-on-droid nix-shell bash vi find - assert_no_command dash xonsh zsh }