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)
| 311 | // never persistently cached — changes to the host filesystem are reflected |
| 312 | // on subsequent calls without needing a cache buster. |
| 313 | func (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", ` |
| 320 | type 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. |
nothing calls this directly
no test coverage detected