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

Method TestWorkspaceFile

core/integration/workspace_test.go:352–375  ·  view source on GitHub ↗

TestWorkspaceFile verifies that Workspace.file returns the correct file content from the host filesystem.

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

Source from the content-addressed store, hash-verified

350// TestWorkspaceFile verifies that Workspace.file returns the correct file
351// content from the host filesystem.
352func (WorkspaceSuite) TestWorkspaceFile(ctx context.Context, t *testctx.T) {
353 c := connect(ctx, t)
354
355 ctr := workspaceBase(t, c).
356 WithNewFile("data.txt", "file content here").
357 With(initDangModule("reader", `
358type Reader {
359 pub content: String!
360
361 new(ws: Workspace!) {
362 self.content = ws.file("data.txt").contents
363 self
364 }
365
366 pub read: String! {
367 content
368 }
369}
370`))
371
372 out, err := ctr.With(daggerCall("reader", "read")).Stdout(ctx)
373 require.NoError(t, err)
374 require.Equal(t, "file content here", strings.TrimSpace(out))
375}
376
377// TestWorkspaceSubdirectory verifies that Workspace.directory can access
378// a subdirectory of the workspace.

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected