(ctx context.Context, t *testctx.T)
| 23 | } |
| 24 | |
| 25 | func (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 |
nothing calls this directly
no test coverage detected