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

Method TestFileErrors

core/integration/container_test.go:2601–2697  ·  view source on GitHub ↗
(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

2599}
2600
2601func (ContainerSuite) TestFileErrors(ctx context.Context, t *testctx.T) {
2602 id := newDirWithFile(t, "some-file", "some-content")
2603
2604 t.Run("path not found", func(ctx context.Context, t *testctx.T) {
2605 _, err := testutil.Query[any](t,
2606 `query Test($id: ID!) {
2607 container {
2608 from(address: "`+alpineImage+`") {
2609 withMountedDirectory(path: "/mnt/dir", source: $id) {
2610 file(path: "/mnt/dir/bogus") {
2611 sync
2612 }
2613 }
2614 }
2615 }
2616 }`, &testutil.QueryOptions{Variables: map[string]any{
2617 "id": id,
2618 }})
2619 require.Error(t, err)
2620 requireErrOut(t, err, "bogus: no such file or directory")
2621 })
2622
2623 t.Run("get directory as file", func(ctx context.Context, t *testctx.T) {
2624 _, err := testutil.Query[any](t,
2625 `query Test($id: ID!) {
2626 container {
2627 from(address: "`+alpineImage+`") {
2628 withMountedDirectory(path: "/mnt/dir", source: $id) {
2629 file(path: "/mnt/dir") {
2630 sync
2631 }
2632 }
2633 }
2634 }
2635 }`, &testutil.QueryOptions{Variables: map[string]any{
2636 "id": id,
2637 }})
2638 require.Error(t, err)
2639 requireErrOut(t, err, "path /mnt/dir is a directory, not a file")
2640 })
2641
2642 t.Run("get path under tmpfs", func(ctx context.Context, t *testctx.T) {
2643 _, err := testutil.Query[any](t,
2644 `{
2645 container {
2646 from(address: "`+alpineImage+`") {
2647 withMountedTemp(path: "/mnt/tmp") {
2648 file(path: "/mnt/tmp/bogus") {
2649 sync
2650 }
2651 }
2652 }
2653 }
2654 }`, nil)
2655 require.Error(t, err)
2656 requireErrOut(t, err, "bogus: cannot retrieve path from tmpfs")
2657 })
2658

Callers

nothing calls this directly

Calls 5

newDirWithFileFunction · 0.85
requireErrOutFunction · 0.85
newCacheFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected