devbox/internal/config/config_test.go
shoemoney 79f91597ad feat(M0): skeleton — cobra CLI, Ed25519 identity, machine config 🦴
- cmd/devbox: join/status/version + stubbed start/stop/publish
- cmd/devbox-hub: version + stubbed serve/token
- internal/identity: Ed25519 keypair gen/save/load (0600), fingerprint
- internal/config: daemon.toml read/write (hub + mounts), XDG-aware dir
- tests: identity round-trip/idempotent, config round-trip

devbox join now generates a device identity and records the hub locally.
2026-06-22 23:01:00 -05:00

34 lines
920 B
Go

package config
import "testing"
func TestDaemonRoundTrip(t *testing.T) {
dir := t.TempDir()
in := Daemon{Hub: "hub.shoemoney.ai", Mounts: []Mount{
{Share: "projects", Local: "/Users/jh/Projects", Hub: "hub.shoemoney.ai"},
{Share: "projects", Subpath: "p22/backend", Local: "/var/www", Hub: "hub.shoemoney.ai", ReadOnly: true},
}}
if err := SaveDaemon(dir, in); err != nil {
t.Fatal(err)
}
out, err := LoadDaemon(dir)
if err != nil {
t.Fatal(err)
}
if out.Hub != in.Hub || len(out.Mounts) != 2 {
t.Fatalf("roundtrip mismatch: %+v", out)
}
if !out.Mounts[1].ReadOnly || out.Mounts[1].Subpath != "p22/backend" {
t.Fatalf("mount fields lost: %+v", out.Mounts[1])
}
}
func TestLoadDaemonMissingIsEmpty(t *testing.T) {
d, err := LoadDaemon(t.TempDir())
if err != nil {
t.Fatal(err)
}
if d.Hub != "" || len(d.Mounts) != 0 {
t.Fatalf("expected empty daemon for missing file, got %+v", d)
}
}