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

Method TestWithMountedFile

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

Source from the content-addressed store, hash-verified

1624}
1625
1626func (ContainerSuite) TestWithMountedFile(ctx context.Context, t *testctx.T) {
1627 c := connect(ctx, t)
1628 dirRes, err := testutil.QueryWithClient[struct {
1629 Directory struct {
1630 WithNewFile struct {
1631 File struct {
1632 ID core.FileID
1633 }
1634 }
1635 }
1636 }](c, t,
1637 `{
1638 directory {
1639 withNewFile(path: "some-dir/sub-file", contents: "sub-content") {
1640 file(path: "some-dir/sub-file") {
1641 id
1642 }
1643 }
1644 }
1645 }`, nil)
1646 require.NoError(t, err)
1647
1648 id := dirRes.Directory.WithNewFile.File.ID
1649
1650 execRes, err := testutil.QueryWithClient[struct {
1651 Container struct {
1652 From struct {
1653 WithMountedFile struct {
1654 WithExec struct {
1655 Stdout string
1656 }
1657 }
1658 }
1659 }
1660 }](c, t,
1661 `query Test($id: ID!) {
1662 container {
1663 from(address: "`+alpineImage+`") {
1664 withMountedFile(path: "/mnt/file", source: $id) {
1665 withExec(args: ["cat", "/mnt/file"]) {
1666 stdout
1667 }
1668 }
1669 }
1670 }
1671 }`, &testutil.QueryOptions{Variables: map[string]any{
1672 "id": id,
1673 }})
1674 require.NoError(t, err)
1675 require.Equal(t, "sub-content", execRes.Container.From.WithMountedFile.WithExec.Stdout)
1676}
1677
1678func (ContainerSuite) TestWithMountedCache(ctx context.Context, t *testctx.T) {
1679 c := connect(ctx, t)

Callers

nothing calls this directly

Calls 3

QueryWithClientFunction · 0.92
connectFunction · 0.70
EqualMethod · 0.65

Tested by

no test coverage detected