From 27696cac81d4444319bb9158037b0da45e213f5e Mon Sep 17 00:00:00 2001 From: Shelvacu Date: Thu, 17 Jul 2025 16:36:40 -0700 Subject: [PATCH] Add tests for _class="nixOnDroid" --- tests/on-device/config-class.bats | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/on-device/config-class.bats diff --git a/tests/on-device/config-class.bats b/tests/on-device/config-class.bats new file mode 100644 index 0000000..c9128d5 --- /dev/null +++ b/tests/on-device/config-class.bats @@ -0,0 +1,25 @@ +# Copyright (c) 2023, see AUTHORS. Licensed under MIT License, see LICENSE. + +load lib + +@test 'successfully loads a config with _class="nixOnDroid"' { + # set up / build / activate the configuration + echo '{ config.system.stateVersion = "24.05"; _class = "nixOnDroid"; }' > ~/.config/nixpkgs/nix-on-droid.nix + _sed -e "s|<>|$FLAKE_URL|g" -e "s|<>|$(detect_system)|g" \ + "$ON_DEVICE_TESTS_DIR/config-flake.nix" \ + > ~/.config/nixpkgs/flake.nix + + nix-on-droid switch --flake ~/.config/nixpkgs#device +} + +@test 'fails to load a config with _class="nixos"' { + # set up / build / activate the configuration + echo '{ config.system.stateVersion = "24.05"; _class = "nixos"; }' > ~/.config/nixpkgs/nix-on-droid.nix + _sed -e "s|<>|$FLAKE_URL|g" -e "s|<>|$(detect_system)|g" \ + "$ON_DEVICE_TESTS_DIR/config-flake.nix" \ + > ~/.config/nixpkgs/flake.nix + + # check that networking.hosts can't map localhost + run nix-on-droid switch --flake ~/.config/nixpkgs#device + [ "$status" -eq 1 ] +}