MCPcopy Create free account
hub / github.com/dagger/dagger / TestContainerDefaultValue

Method TestContainerDefaultValue

core/integration/module_python_test.go:2177–2204  ·  view source on GitHub ↗
(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

2175}
2176
2177func (PythonSuite) TestContainerDefaultValue(ctx context.Context, t *testctx.T) {
2178 c := connect(ctx, t)
2179
2180 modGen := pythonModInit(t, c, `
2181from typing import Annotated
2182import dataclasses
2183import dagger
2184from dagger import function, object_type
2185
2186@object_type
2187class Test:
2188 @function
2189 async def version(
2190 self,
2191 ctr: Annotated[dagger.Container, dagger.DefaultAddress("alpine:3.19")],
2192 ) -> str:
2193 return await ctr.with_exec(["cat", "/etc/alpine-release"]).stdout()
2194`)
2195
2196 out, err := modGen.With(daggerCall("version")).Stdout(ctx)
2197 require.NoError(t, err)
2198 require.Contains(t, out, "3.19") // Alpine version contains "3.19.0"
2199
2200 // Test that we can override the default via constructor
2201 out2, err := modGen.With(daggerCall("version", "--ctr=alpine:3.18")).Stdout(ctx)
2202 require.NoError(t, err)
2203 require.Contains(t, out2, "3.18")
2204}
2205
2206// TestEnumDefaultValue verifies that an enum used as a default for a
2207// function argument is honored both at call time and in the --help text.

Callers

nothing calls this directly

Calls 6

pythonModInitFunction · 0.85
daggerCallFunction · 0.85
connectFunction · 0.70
ContainsMethod · 0.65
StdoutMethod · 0.45
WithMethod · 0.45

Tested by

no test coverage detected