MCPcopy Create free account
hub / github.com/go-task/task / TestIncludesInternal

Function TestIncludesInternal

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

Source from the content-addressed store, hash-verified

1497}
1498
1499func TestIncludesInternal(t *testing.T) {
1500 t.Parallel()
1501
1502 const dir = "testdata/internal_task"
1503 tests := []struct {
1504 name string
1505 task string
1506 expectedErr bool
1507 expectedOutput string
1508 }{
1509 {"included internal task via task", "task-1", false, "Hello, World!\n"},
1510 {"included internal task via dep", "task-2", false, "Hello, World!\n"},
1511 {"included internal direct", "included:task-3", true, "task: No tasks with description available. Try --list-all to list all tasks\n"},
1512 }
1513
1514 for _, test := range tests {
1515 t.Run(test.name, func(t *testing.T) {
1516 t.Parallel()
1517
1518 var buff bytes.Buffer
1519 e := task.NewExecutor(
1520 task.WithDir(dir),
1521 task.WithStdout(&buff),
1522 task.WithStderr(&buff),
1523 task.WithSilent(true),
1524 )
1525 require.NoError(t, e.Setup())
1526
1527 err := e.Run(t.Context(), &task.Call{Task: test.task})
1528 if test.expectedErr {
1529 require.Error(t, err)
1530 } else {
1531 require.NoError(t, err)
1532 }
1533 assert.Equal(t, test.expectedOutput, buff.String())
1534 })
1535 }
1536}
1537
1538func TestIncludesFlatten(t *testing.T) {
1539 t.Parallel()

Callers

nothing calls this directly

Calls 5

SetupMethod · 0.95
RunMethod · 0.95
RunMethod · 0.45
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…