(t *testing.T)
| 406 | } |
| 407 | |
| 408 | func (fct fileContentTest) Run(t *testing.T) { |
| 409 | t.Helper() |
| 410 | |
| 411 | for f := range fct.Files { |
| 412 | _ = os.Remove(filepathext.SmartJoin(fct.Dir, f)) |
| 413 | } |
| 414 | |
| 415 | e := task.NewExecutor( |
| 416 | task.WithDir(fct.Dir), |
| 417 | task.WithTempDir(task.TempDir{ |
| 418 | Remote: filepathext.SmartJoin(fct.Dir, ".task"), |
| 419 | Fingerprint: filepathext.SmartJoin(fct.Dir, ".task"), |
| 420 | }), |
| 421 | task.WithEntrypoint(fct.Entrypoint), |
| 422 | task.WithStdout(io.Discard), |
| 423 | task.WithStderr(io.Discard), |
| 424 | ) |
| 425 | |
| 426 | require.NoError(t, e.Setup(), "e.Setup()") |
| 427 | require.NoError(t, e.Run(t.Context(), &task.Call{Task: fct.Target}), "e.Run(target)") |
| 428 | for name, expectContent := range fct.Files { |
| 429 | t.Run(fct.name(name), func(t *testing.T) { |
| 430 | path := filepathext.SmartJoin(e.Dir, name) |
| 431 | b, err := os.ReadFile(path) |
| 432 | require.NoError(t, err, "Error reading file") |
| 433 | s := string(b) |
| 434 | if fct.TrimSpace { |
| 435 | s = strings.TrimSpace(s) |
| 436 | } |
| 437 | assert.Equal(t, expectContent, s, "unexpected file content in %s", path) |
| 438 | }) |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | func TestGenerates(t *testing.T) { |
| 443 | t.Parallel() |
no test coverage detected