| 565 | } |
| 566 | |
| 567 | func (ShellSuite) TestPassingID(ctx context.Context, t *testctx.T) { |
| 568 | c := connect(ctx, t) |
| 569 | |
| 570 | source := `package main |
| 571 | |
| 572 | import "context" |
| 573 | |
| 574 | type Test struct{} |
| 575 | |
| 576 | func (m *Test) DirectoryID(ctx context.Context) (string, error) { |
| 577 | id, err := dag.Directory().WithNewFile("foo", "bar").ID(ctx) |
| 578 | return string(id), err |
| 579 | } |
| 580 | ` |
| 581 | script := "node $(directory-id) | file foo | contents" |
| 582 | |
| 583 | out, err := modInit(t, c, "go", source). |
| 584 | With(daggerShell(script)). |
| 585 | Stdout(ctx) |
| 586 | |
| 587 | require.NoError(t, err) |
| 588 | require.Equal(t, "bar", out) |
| 589 | } |
| 590 | |
| 591 | func (ShellSuite) TestInterfaceReturnConcreteFunction(ctx context.Context, t *testctx.T) { |
| 592 | c := connect(ctx, t) |