(t *testing.T)
| 147 | } |
| 148 | |
| 149 | func TestPortOffset(t *testing.T) { |
| 150 | t.Parallel() |
| 151 | |
| 152 | root := "/tmp/coder/worktree-a" |
| 153 | offset := portOffset(root) |
| 154 | assert.Equal(t, offset, portOffset(root)) |
| 155 | assert.GreaterOrEqual(t, offset, 0) |
| 156 | assert.Less(t, offset, 1000) |
| 157 | assert.Equal(t, 0, offset%10) |
| 158 | |
| 159 | var foundDifferent bool |
| 160 | for _, otherRoot := range []string{ |
| 161 | "/tmp/coder/worktree-b", |
| 162 | "/tmp/coder/worktree-c", |
| 163 | "/tmp/coder/worktree-d", |
| 164 | } { |
| 165 | if portOffset(otherRoot) != offset { |
| 166 | foundDifferent = true |
| 167 | break |
| 168 | } |
| 169 | } |
| 170 | assert.True(t, foundDifferent, "expected typical worktree paths to use different offsets") |
| 171 | } |
| 172 | |
| 173 | func TestApplyPortOffsetSkipsExplicitPorts(t *testing.T) { |
| 174 | t.Parallel() |
nothing calls this directly
no test coverage detected