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

Method TestWorkspaceArg

core/integration/workspace_test.go:215–246  ·  view source on GitHub ↗

TestWorkspaceArg verifies that a module function accepting a Workspace argument can access the host filesystem.

(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

213// TestWorkspaceArg verifies that a module function accepting a Workspace
214// argument can access the host filesystem.
215func (WorkspaceSuite) TestWorkspaceArg(ctx context.Context, t *testctx.T) {
216 c := connect(ctx, t)
217
218 ctr := workspaceBase(t, c).
219 WithNewFile("hello.txt", "hello from workspace").
220 With(initDangModule("greeter", `
221type Greeter {
222 pub source: Directory!
223
224 new(source: Workspace!) {
225 self.source = source.directory(".")
226 self
227 }
228
229 pub read: String! {
230 source.file("hello.txt").contents
231 }
232}
233`))
234
235 t.Run("dagger call", func(ctx context.Context, t *testctx.T) {
236 out, err := ctr.With(daggerCall("greeter", "read")).Stdout(ctx)
237 require.NoError(t, err)
238 require.Equal(t, "hello from workspace", strings.TrimSpace(out))
239 })
240
241 t.Run("dagger shell", func(ctx context.Context, t *testctx.T) {
242 out, err := ctr.With(daggerShell("greeter | read")).Stdout(ctx)
243 require.NoError(t, err)
244 require.Equal(t, "hello from workspace", out)
245 })
246}
247
248// TestWorkspaceDirectoryEntries verifies that Workspace.directory returns the
249// correct entries from the host filesystem.

Callers

nothing calls this directly

Calls 10

workspaceBaseFunction · 0.85
daggerCallFunction · 0.85
daggerShellFunction · 0.85
connectFunction · 0.70
initDangModuleFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.65
WithMethod · 0.45
WithNewFileMethod · 0.45
StdoutMethod · 0.45

Tested by

no test coverage detected