package nixbuild_test import ( "slices" "testing" "git.gensokyo.uk/yonah/nixbuild" ) func TestNix(t *testing.T) { testCases := []struct { name string arg []string want []string }{ {"build", []string{"build"}, []string{"nix", "--extra-experimental-features", "nix-command flakes", "build"}}, {"build workflow", []string{"build", `--out-link "result"`, "--print-out-paths", "--print-build-logs"}, []string{"nix", "--extra-experimental-features", "nix-command flakes", "build", `--out-link "result"`, "--print-out-paths", "--print-build-logs"}}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { got := nixbuild.Nix(t.Context(), tc.arg...) if !slices.Equal(got.Args, tc.want) { t.Errorf("Nix: %#v, want %#v", got.Args, tc.want) } }) } } func TestInstallable(t *testing.T) { testCases := []struct { name, flake, host, want string }{ {"satori", "/var/lib/persist/nixos", "satori", "/var/lib/persist/nixos#nixosConfigurations.satori.config.system.build.toplevel"}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { got := nixbuild.NixOSInstallable(tc.flake, tc.host) if got != tc.want { t.Errorf("Installable(%q, %q): %q, want %q", tc.flake, tc.host, got, tc.want) } }) } }