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

Function TestApplyPortOffsetSkipsExplicitPorts

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

Source from the content-addressed store, hash-verified

171}
172
173func TestApplyPortOffsetSkipsExplicitPorts(t *testing.T) {
174 t.Parallel()
175
176 projectRoot := "/tmp/coder/worktree-offset"
177 for i := range 100 {
178 candidate := fmt.Sprintf("/tmp/coder/worktree-offset-%d", i)
179 if portOffset(candidate) != 0 {
180 projectRoot = candidate
181 break
182 }
183 }
184 offset := portOffset(projectRoot)
185 require.NotZero(t, offset)
186
187 cfg := &devConfig{
188 apiPort: 3000,
189 webPort: 8080,
190 proxyPort: 3010,
191 coderMetricsPort: 2114,
192 portOffsetEnabled: true,
193 projectRoot: projectRoot,
194 portExplicit: portExplicit{
195 web: true,
196 metrics: true,
197 },
198 }
199 cfg.applyPortOffset()
200
201 assert.Equal(t, int64(3000+offset), cfg.apiPort)
202 assert.Equal(t, int64(8080), cfg.webPort)
203 assert.Equal(t, int64(3010+offset), cfg.proxyPort)
204 assert.Equal(t, int64(2114), cfg.coderMetricsPort)
205 assert.Equal(t, portSourceOffset, cfg.apiPortSource)
206 assert.Equal(t, portSourceExplicit, cfg.webPortSource)
207 assert.Equal(t, portSourceOffset, cfg.proxyPortSource)
208 assert.Equal(t, portSourceExplicit, cfg.metricsPortSource)
209}
210
211func TestApplyPortOffsetDisabledUsesDefaultPorts(t *testing.T) {
212 t.Parallel()

Callers

nothing calls this directly

Calls 3

applyPortOffsetMethod · 0.95
portOffsetFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected