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

Method TestFile

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

Source from the content-addressed store, hash-verified

2530}
2531
2532func (ContainerSuite) TestFile(ctx context.Context, t *testctx.T) {
2533 c := connect(ctx, t)
2534 id := newDirWithFile(t, "some-file", "some-content-")
2535
2536 writeRes, err := testutil.QueryWithClient[struct {
2537 Container struct {
2538 From struct {
2539 WithMountedDirectory struct {
2540 WithMountedDirectory struct {
2541 WithExec struct {
2542 File struct {
2543 ID core.FileID
2544 }
2545 }
2546 }
2547 }
2548 }
2549 }
2550 }](c, t,
2551 `query Test($id: ID!) {
2552 container {
2553 from(address: "`+alpineImage+`") {
2554 withMountedDirectory(path: "/mnt/dir", source: $id) {
2555 withMountedDirectory(path: "/mnt/dir/overlap", source: $id) {
2556 withExec(args: ["sh", "-c", "echo -n appended >> /mnt/dir/overlap/some-file"]) {
2557 file(path: "/mnt/dir/overlap/some-file") {
2558 id
2559 }
2560 }
2561 }
2562 }
2563 }
2564 }
2565 }`, &testutil.QueryOptions{Variables: map[string]any{
2566 "id": id,
2567 }})
2568 require.NoError(t, err)
2569
2570 writtenID := writeRes.Container.From.WithMountedDirectory.WithMountedDirectory.WithExec.File.ID
2571
2572 execRes, err := testutil.QueryWithClient[struct {
2573 Container struct {
2574 From struct {
2575 WithMountedFile struct {
2576 WithExec struct {
2577 Stdout string
2578 }
2579 }
2580 }
2581 }
2582 }](c, t,
2583 `query Test($id: ID!) {
2584 container {
2585 from(address: "`+alpineImage+`") {
2586 withMountedFile(path: "/mnt/file", source: $id) {
2587 withExec(args: ["cat", "/mnt/file"]) {
2588 stdout
2589 }

Callers

nothing calls this directly

Calls 4

QueryWithClientFunction · 0.92
newDirWithFileFunction · 0.85
connectFunction · 0.70
EqualMethod · 0.65

Tested by

no test coverage detected