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

Function TestInternalTask

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

Source from the content-addressed store, hash-verified

1677}
1678
1679func TestInternalTask(t *testing.T) {
1680 t.Parallel()
1681
1682 const dir = "testdata/internal_task"
1683 tests := []struct {
1684 name string
1685 task string
1686 expectedErr bool
1687 expectedOutput string
1688 }{
1689 {"internal task via task", "task-1", false, "Hello, World!\n"},
1690 {"internal task via dep", "task-2", false, "Hello, World!\n"},
1691 {"internal direct", "task-3", true, ""},
1692 }
1693
1694 for _, test := range tests {
1695 t.Run(test.name, func(t *testing.T) {
1696 t.Parallel()
1697
1698 var buff bytes.Buffer
1699 e := task.NewExecutor(
1700 task.WithDir(dir),
1701 task.WithStdout(&buff),
1702 task.WithStderr(&buff),
1703 task.WithSilent(true),
1704 )
1705 require.NoError(t, e.Setup())
1706
1707 err := e.Run(t.Context(), &task.Call{Task: test.task})
1708 if test.expectedErr {
1709 require.Error(t, err)
1710 } else {
1711 require.NoError(t, err)
1712 }
1713 assert.Equal(t, test.expectedOutput, buff.String())
1714 })
1715 }
1716}
1717
1718func TestIncludesShadowedDefault(t *testing.T) {
1719 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…