(ctx context.Context, t *testctx.T)
| 2175 | } |
| 2176 | |
| 2177 | func (PythonSuite) TestContainerDefaultValue(ctx context.Context, t *testctx.T) { |
| 2178 | c := connect(ctx, t) |
| 2179 | |
| 2180 | modGen := pythonModInit(t, c, ` |
| 2181 | from typing import Annotated |
| 2182 | import dataclasses |
| 2183 | import dagger |
| 2184 | from dagger import function, object_type |
| 2185 | |
| 2186 | @object_type |
| 2187 | class 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. |
nothing calls this directly
no test coverage detected