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

Method TestInit

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

Source from the content-addressed store, hash-verified

23}
24
25func (PythonSuite) TestInit(ctx context.Context, t *testctx.T) {
26 t.Run("from scratch", func(ctx context.Context, t *testctx.T) {
27 c := connect(ctx, t)
28
29 out, err := daggerCliBase(t, c).
30 With(daggerInitPython()).
31 With(daggerCall("container-echo", "--string-arg", "hello", "stdout")).
32 Stdout(ctx)
33
34 require.NoError(t, err)
35 require.Equal(t, "hello\n", out)
36 })
37
38 t.Run("with different root", func(ctx context.Context, t *testctx.T) {
39 c := connect(ctx, t)
40
41 out, err := daggerCliBase(t, c).
42 With(daggerInitPythonAt("child")).
43 With(daggerCallAt("child", "container-echo", "--string-arg", "hello", "stdout")).
44 Stdout(ctx)
45
46 require.NoError(t, err)
47 require.Equal(t, "hello\n", out)
48 })
49
50 t.Run("on develop", func(ctx context.Context, t *testctx.T) {
51 c := connect(ctx, t)
52
53 out, err := daggerCliBase(t, c).
54 With(daggerExec("init", "--source=.")).
55 With(daggerExec("develop", "--sdk=python", "--source=.")).
56 With(daggerCall("container-echo", "--string-arg", "hello", "stdout")).
57 Stdout(ctx)
58
59 require.NoError(t, err)
60 require.Equal(t, "hello\n", out)
61 })
62
63 t.Run("doesn't create files in develop with existing pyproject.toml", func(ctx context.Context, t *testctx.T) {
64 c := connect(ctx, t)
65
66 _, err := daggerCliBase(t, c).
67 With(daggerExec("init", "--source=.")).
68 With(pyprojectExtra(nil, "")).
69 With(daggerExec("develop", "--sdk=python", "--source=.")).
70 Sync(ctx)
71
72 requireErrOut(t, err, "no python files found")
73 })
74
75 t.Run("uses expected field casing", func(ctx context.Context, t *testctx.T) {
76 c := connect(ctx, t)
77
78 out, err := daggerCliBase(t, c).
79 With(daggerInitPython("--name=hello-world")).
80 With(fileContents("src/hello_world/__init__.py", `
81 from dagger import field, function, object_type
82

Callers

nothing calls this directly

Calls 15

daggerCliBaseFunction · 0.85
daggerInitPythonFunction · 0.85
daggerCallFunction · 0.85
daggerInitPythonAtFunction · 0.85
daggerCallAtFunction · 0.85
daggerExecFunction · 0.85
pyprojectExtraFunction · 0.85
requireErrOutFunction · 0.85
fileContentsFunction · 0.85
daggerQueryFunction · 0.85
daggerCliFileFunction · 0.85
connectFunction · 0.70

Tested by

no test coverage detected