Files
Reims-Go/internal/macos/macosdriver/clone_test.go
T
Nwflower d74868589d fix(macos): give CoW clones their own SSH port forward
CloneCoW built reims.CreateOpts without SSHPort even though the field and
the --ssh-port argument both exist, so every CoW clone came up with no host
SSH forward. MCP temporary sessions and any other clone then failed every
SSH-based guest tool (guest_exec, guest_wait_ready, test_run) with a port
that nothing listened on.

Pick the next free port after the source VM's forward and pass it to create;
a source without forwarding still yields a clone without one. Add
TestCloneSSHPort for the selection logic.

model: deepseek/deepseek-v4.1-flash
agent: lead (DeepSeek Harness)
2026-12-04 05:39:40 -07:00

26 lines
750 B
Go

package macosdriver
import "testing"
func TestCloneSSHPort(t *testing.T) {
never := func(int) bool { return false }
all := func(int) bool { return true }
for _, tt := range []struct {
name string
sourcePort int
inUse func(int) bool
want int
}{
{"source without forwarding stays off", 0, never, 0},
{"next free port after the source", 2222, never, 2223},
{"skips ports that are already bound", 2222, func(p int) bool { return p <= 2225 }, 2226},
{"falls back when the range is exhausted", 65533, all, 65534},
} {
t.Run(tt.name, func(t *testing.T) {
if got := cloneSSHPort(tt.sourcePort, tt.inUse); got != tt.want {
t.Fatalf("cloneSSHPort(%d) = %d, want %d", tt.sourcePort, got, tt.want)
}
})
}
}