(ctx context.Context, t *testctx.T)
| 458 | } |
| 459 | |
| 460 | func (ShellSuite) TestLoadAnotherModule(ctx context.Context, t *testctx.T) { |
| 461 | test := `package main |
| 462 | |
| 463 | type Test struct{} |
| 464 | |
| 465 | func (m *Test) Bar() string { |
| 466 | return "testbar" |
| 467 | } |
| 468 | ` |
| 469 | |
| 470 | foo := `package main |
| 471 | |
| 472 | func New() *Foo { |
| 473 | return &Foo{ |
| 474 | Bar: "foobar", |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | type Foo struct{ |
| 479 | Bar string |
| 480 | } |
| 481 | ` |
| 482 | t.Run("main object", func(ctx context.Context, t *testctx.T) { |
| 483 | c := connect(ctx, t) |
| 484 | out, err := modInit(t, c, "go", test). |
| 485 | With(daggerExec("init", "--sdk=go", "--source=foo", "foo")). |
| 486 | With(sdkSourceAt("foo", "go", foo)). |
| 487 | With(daggerShell("foo")). |
| 488 | Stdout(ctx) |
| 489 | require.NoError(t, err) |
| 490 | require.Regexp(t, `Foo@xxh3:[a-f0-9]{16}`, out) |
| 491 | }) |
| 492 | |
| 493 | t.Run("stateful", func(ctx context.Context, t *testctx.T) { |
| 494 | c := connect(ctx, t) |
| 495 | out, err := modInit(t, c, "go", test). |
| 496 | With(daggerExec("init", "--sdk=go", "--source=foo", "foo")). |
| 497 | With(sdkSourceAt("foo", "go", foo)). |
| 498 | With(daggerShell(".cd foo; bar")). |
| 499 | Stdout(ctx) |
| 500 | require.NoError(t, err) |
| 501 | require.Contains(t, out, "foobar") |
| 502 | }) |
| 503 | |
| 504 | t.Run("stateless", func(ctx context.Context, t *testctx.T) { |
| 505 | c := connect(ctx, t) |
| 506 | modGen := modInit(t, c, "go", test). |
| 507 | With(daggerExec("init", "--sdk=go", "--source=foo", "foo")). |
| 508 | With(sdkSourceAt("foo", "go", foo)) |
| 509 | |
| 510 | out, err := modGen. |
| 511 | With(daggerShell("foo | bar")). |
| 512 | Stdout(ctx) |
| 513 | require.NoError(t, err) |
| 514 | require.Equal(t, "foobar", out) |
| 515 | |
| 516 | out, err = modGen. |
| 517 | With(daggerShell("bar")). |
nothing calls this directly
no test coverage detected