(ctx context.Context, t *testctx.T)
| 690 | } |
| 691 | |
| 692 | func (CLISuite) TestDaggerInstall(ctx context.Context, t *testctx.T) { |
| 693 | t.Run("local", func(ctx context.Context, t *testctx.T) { |
| 694 | c := connect(ctx, t) |
| 695 | |
| 696 | base := goGitBase(t, c). |
| 697 | WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). |
| 698 | WithWorkdir("/work/subdir/dep"). |
| 699 | With(daggerExec("init", "--source=.", "--name=dep", "--sdk=go")). |
| 700 | WithNewFile("/work/subdir/dep/main.go", `package main |
| 701 | |
| 702 | import "context" |
| 703 | |
| 704 | type Dep struct {} |
| 705 | |
| 706 | func (m *Dep) DepFn(ctx context.Context, str string) string { return str } |
| 707 | `, |
| 708 | ). |
| 709 | WithWorkdir("/work"). |
| 710 | With(daggerExec("init", "--source=test", "--name=test", "--sdk=go", "test")). |
| 711 | With(daggerExec("install", "-m=test", "./subdir/dep")). |
| 712 | WithNewFile("/work/test/main.go", `package main |
| 713 | |
| 714 | import "context" |
| 715 | |
| 716 | type Test struct {} |
| 717 | |
| 718 | func (m *Test) Fn(ctx context.Context) (string, error) { return dag.Dep().DepFn(ctx, "hi dep") } |
| 719 | `, |
| 720 | ) |
| 721 | |
| 722 | // try invoking it from a few different paths, just for more corner case coverage |
| 723 | |
| 724 | t.Run("from src dir", func(ctx context.Context, t *testctx.T) { |
| 725 | out, err := base.WithWorkdir("test").With(daggerCall("fn")).Stdout(ctx) |
| 726 | require.NoError(t, err) |
| 727 | require.Equal(t, "hi dep", strings.TrimSpace(out)) |
| 728 | }) |
| 729 | |
| 730 | t.Run("from src root", func(ctx context.Context, t *testctx.T) { |
| 731 | out, err := base.With(daggerCallAt("test", "fn")).Stdout(ctx) |
| 732 | require.NoError(t, err) |
| 733 | require.Equal(t, "hi dep", strings.TrimSpace(out)) |
| 734 | }) |
| 735 | |
| 736 | t.Run("from root", func(ctx context.Context, t *testctx.T) { |
| 737 | out, err := base.WithWorkdir("/").With(daggerCallAt("work/test", "fn")).Stdout(ctx) |
| 738 | require.NoError(t, err) |
| 739 | require.Equal(t, "hi dep", strings.TrimSpace(out)) |
| 740 | }) |
| 741 | |
| 742 | t.Run("from dep parent", func(ctx context.Context, t *testctx.T) { |
| 743 | out, err := base.WithWorkdir("/work/subdir").With(daggerCallAt("../test", "fn")).Stdout(ctx) |
| 744 | require.NoError(t, err) |
| 745 | require.Equal(t, "hi dep", strings.TrimSpace(out)) |
| 746 | }) |
| 747 | |
| 748 | t.Run("from dep dir", func(ctx context.Context, t *testctx.T) { |
| 749 | out, err := base.WithWorkdir("/work/subdir/dep").With(daggerCallAt("../../test", "fn")).Stdout(ctx) |
nothing calls this directly
no test coverage detected