MCPcopy Index your code
hub / github.com/go-task/task / TestErrorCode

Function TestErrorCode

task_test.go:2477–2517  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2475}
2476
2477func TestErrorCode(t *testing.T) {
2478 t.Parallel()
2479
2480 const dir = "testdata/error_code"
2481 tests := []struct {
2482 name string
2483 task string
2484 expected int
2485 }{
2486 {
2487 name: "direct task",
2488 task: "direct",
2489 expected: 42,
2490 }, {
2491 name: "indirect task",
2492 task: "indirect",
2493 expected: 42,
2494 },
2495 }
2496
2497 for _, test := range tests {
2498 t.Run(test.name, func(t *testing.T) {
2499 t.Parallel()
2500
2501 var buff bytes.Buffer
2502 e := task.NewExecutor(
2503 task.WithDir(dir),
2504 task.WithStdout(&buff),
2505 task.WithStderr(&buff),
2506 task.WithSilent(true),
2507 )
2508 require.NoError(t, e.Setup())
2509
2510 err := e.Run(t.Context(), &task.Call{Task: test.task})
2511 require.Error(t, err)
2512 taskRunErr, ok := err.(*errors.TaskRunError)
2513 assert.True(t, ok, "cannot cast returned error to *task.TaskRunError")
2514 assert.Equal(t, test.expected, taskRunErr.TaskExitCode(), "unexpected exit code from task")
2515 })
2516 }
2517}
2518
2519func TestEvaluateSymlinksInPaths(t *testing.T) { // nolint:paralleltest // cannot run in parallel
2520 const dir = "testdata/evaluate_symlinks_in_paths"

Callers

nothing calls this directly

Calls 5

SetupMethod · 0.95
RunMethod · 0.95
TaskExitCodeMethod · 0.80
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…