Skip to content

Commit 27696ca

Browse files
Shelvacut184256
authored andcommitted
Add tests for _class="nixOnDroid"
1 parent a25bb0a commit 27696ca

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/on-device/config-class.bats

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2023, see AUTHORS. Licensed under MIT License, see LICENSE.
2+
3+
load lib
4+
5+
@test 'successfully loads a config with _class="nixOnDroid"' {
6+
# set up / build / activate the configuration
7+
echo '{ config.system.stateVersion = "24.05"; _class = "nixOnDroid"; }' > ~/.config/nixpkgs/nix-on-droid.nix
8+
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
9+
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
10+
> ~/.config/nixpkgs/flake.nix
11+
12+
nix-on-droid switch --flake ~/.config/nixpkgs#device
13+
}
14+
15+
@test 'fails to load a config with _class="nixos"' {
16+
# set up / build / activate the configuration
17+
echo '{ config.system.stateVersion = "24.05"; _class = "nixos"; }' > ~/.config/nixpkgs/nix-on-droid.nix
18+
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
19+
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
20+
> ~/.config/nixpkgs/flake.nix
21+
22+
# check that networking.hosts can't map localhost
23+
run nix-on-droid switch --flake ~/.config/nixpkgs#device
24+
[ "$status" -eq 1 ]
25+
}

0 commit comments

Comments
 (0)