TestWorkspaceFile verifies that Workspace.file returns the correct file content from the host filesystem.
(ctx context.Context, t *testctx.T)
| 350 | // TestWorkspaceFile verifies that Workspace.file returns the correct file |
| 351 | // content from the host filesystem. |
| 352 | func (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", ` |
| 358 | type 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. |
nothing calls this directly
no test coverage detected