MCPcopy Index your code
hub / github.com/coder/coder / TestApplyPortOffsetDisabledUsesDefaultPorts

Function TestApplyPortOffsetDisabledUsesDefaultPorts

scripts/develop/main_test.go:211–243  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

209}
210
211func TestApplyPortOffsetDisabledUsesDefaultPorts(t *testing.T) {
212 t.Parallel()
213
214 projectRoot := "/tmp/coder/worktree-offset"
215 for i := range 100 {
216 candidate := fmt.Sprintf("/tmp/coder/worktree-offset-disabled-%d", i)
217 if portOffset(candidate) != 0 {
218 projectRoot = candidate
219 break
220 }
221 }
222 require.NotZero(t, portOffset(projectRoot))
223
224 cfg := &devConfig{
225 apiPort: 3000,
226 webPort: 8080,
227 proxyPort: 3010,
228 coderMetricsPort: 2114,
229 projectRoot: projectRoot,
230 }
231 cfg.applyPortOffset()
232
233 assert.Equal(t, int64(3000), cfg.apiPort)
234 assert.Equal(t, int64(8080), cfg.webPort)
235 assert.Equal(t, int64(3010), cfg.proxyPort)
236 assert.Equal(t, int64(2114), cfg.coderMetricsPort)
237 assert.Zero(t, cfg.portOffset)
238 assert.Empty(t, cfg.apiPortSource)
239 assert.Empty(t, cfg.webPortSource)
240 assert.Empty(t, cfg.proxyPortSource)
241 assert.Empty(t, cfg.metricsPortSource)
242 assert.Equal(t, "API: 3000", portBannerLine("API", cfg.apiPort, cfg.apiPortSource, cfg.portOffset))
243}
244
245func TestPortOffsetDefaultPortsDoNotOverlap(t *testing.T) {
246 t.Parallel()

Callers

nothing calls this directly

Calls 5

applyPortOffsetMethod · 0.95
portOffsetFunction · 0.85
portBannerLineFunction · 0.85
EqualMethod · 0.45
EmptyMethod · 0.45

Tested by

no test coverage detected