1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

add tests to previous

This commit is contained in:
Kevin Ard
2020-11-13 16:24:34 -05:00
parent 9bed7f7a9b
commit 347c796662
2 changed files with 61 additions and 1 deletions

View File

@@ -474,10 +474,58 @@ func TestLabelInList(t *testing.T) {
Stderr: &buff,
}
assert.NoError(t, e.Setup())
e.PrintTasksHelp()
e.PrintTasksHelp(false)
assert.Contains(t, buff.String(), "foobar")
}
// task -al case 1: listAll list all tasks
func TestListAllShowsNoDesc(t *testing.T) {
const dir = "testdata/list_mixed_desc"
var buff bytes.Buffer
e := task.Executor{
Dir: dir,
Stdout: &buff,
Stderr: &buff,
}
assert.NoError(t, e.Setup())
var title string
e.PrintTasksHelp(true)
for _, title = range []string{
"foo",
"voo",
"doo",
} {
assert.Contains(t, buff.String(), title)
}
}
// task -al case 2: !listAll list some tasks (only those with desc)
func TestListCanListDescOnly(t *testing.T) {
const dir = "testdata/list_mixed_desc"
var buff bytes.Buffer
e := task.Executor{
Dir: dir,
Stdout: &buff,
Stderr: &buff,
}
assert.NoError(t, e.Setup())
e.PrintTasksHelp(false)
var title string
assert.Contains(t, buff.String(), "foo")
for _, title = range []string{
"voo",
"doo",
} {
assert.NotContains(t, buff.String(), title)
}
}
func TestStatusVariables(t *testing.T) {
const dir = "testdata/status_vars"

12
testdata/list_mixed_desc/Taskfile.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
version: '3'
tasks:
foo:
label: "foobar"
desc: "foo has desc and label"
voo:
label: "voo has no desc"
doo:
label: "doo has desc, no label"