MCPcopy
hub / github.com/docker/compose / TestRunVariablesAllowsTemplatedPortFields

Function TestRunVariablesAllowsTemplatedPortFields

cmd/compose/options_test.go:309–343  ·  cmd/compose/options_test.go::TestRunVariablesAllowsTemplatedPortFields
(t *testing.T)

Source from the content-addressed store, hash-verified

307}
308
309func TestRunVariablesAllowsTemplatedPortFields(t *testing.T) {
310 ctrl := gomock.NewController(t)
311 defer ctrl.Finish()
312
313 dir := t.TempDir()
314 composePath := filepath.Join(dir, "compose.yaml")
315 assert.NilError(t, os.WriteFile(composePath, []byte(`
316name: remote-defaults
317services:
318 web:
319 image: nginx
320 ports:
321 - host_ip: "${LXKNS_ADDRESS:-127.0.0.1}"
322 published: "${LXKNS_PORT:-5010}"
323 target: 80
324 protocol: tcp
325`), 0o600))
326
327 buf := new(bytes.Buffer)
328 cli := mocks.NewMockCli(ctrl)
329 cli.EXPECT().Out().Return(streams.NewOut(buf)).AnyTimes()
330
331 opts := configOptions{
332 Format: "json",
333 ProjectOptions: &ProjectOptions{
334 ConfigPaths: []string{composePath},
335 ProjectDir: dir,
336 },
337 }
338 assert.NilError(t, runVariables(t.Context(), cli, opts, nil))
339
340 output := buf.String()
341 assert.Assert(t, strings.Contains(output, `"LXKNS_ADDRESS"`), output)
342 assert.Assert(t, strings.Contains(output, `"LXKNS_PORT"`), output)
343}
344
345func TestConfirmRemoteIncludes(t *testing.T) {
346 ctrl := gomock.NewController(t)

Callers

nothing calls this directly

Calls 7

EXPECTMethod · 0.95
NewMockCliFunction · 0.92
runVariablesFunction · 0.85
TempDirMethod · 0.80
WriteFileMethod · 0.80
OutMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected