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

Method TestWorkspaceNotCached

core/integration/workspace_test.go:313–348  ·  view source on GitHub ↗

TestWorkspaceNotCached verifies that functions accepting Workspace args are never persistently cached — changes to the host filesystem are reflected on subsequent calls without needing a cache buster.

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

Source from the content-addressed store, hash-verified

311// never persistently cached — changes to the host filesystem are reflected
312// on subsequent calls without needing a cache buster.
313func (WorkspaceSuite) TestWorkspaceNotCached(ctx context.Context, t *testctx.T) {
314 c := connect(ctx, t)
315
316 // Set up a module that lists workspace entries.
317 base := workspaceBase(t, c).
318 WithNewFile("original.txt", "original").
319 With(initDangModule("cachechk", `
320type Cachechk {
321 pub source: Directory!
322
323 new(source: Workspace!) {
324 self.source = source.directory(".")
325 self
326 }
327
328 pub ls: [String!] {
329 source.entries
330 }
331}
332`))
333
334 // First call — should see original.txt.
335 out, err := base.With(daggerCall("cachechk", "ls")).Stdout(ctx)
336 require.NoError(t, err)
337 require.Contains(t, out, "original.txt")
338 require.NotContains(t, out, "added.txt")
339
340 // Add a file and call again — should see the new file without any cache buster.
341 out, err = base.
342 WithNewFile("added.txt", "added").
343 With(daggerCall("cachechk", "ls")).
344 Stdout(ctx)
345 require.NoError(t, err)
346 require.Contains(t, out, "original.txt")
347 require.Contains(t, out, "added.txt")
348}
349
350// TestWorkspaceFile verifies that Workspace.file returns the correct file
351// content from the host filesystem.

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected