mirror of
https://github.com/go-task/task.git
synced 2025-01-04 03:48:02 +02:00
Add basic unit tests for label attribute
This commit is contained in:
parent
9f83311931
commit
4bc183a8a1
84
task_test.go
84
task_test.go
@ -384,6 +384,90 @@ func TestStatusChecksum(t *testing.T) {
|
||||
assert.Equal(t, `task: Task "build" is up to date`+"\n", buff.String())
|
||||
}
|
||||
|
||||
func TestLabelUpToDate(t *testing.T) {
|
||||
const dir = "testdata/label_uptodate"
|
||||
|
||||
var buff bytes.Buffer
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
Stdout: &buff,
|
||||
Stderr: &buff,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "foo"}))
|
||||
assert.Contains(t, buff.String(), "foobar")
|
||||
}
|
||||
|
||||
func TestLabelSummary(t *testing.T) {
|
||||
const dir = "testdata/label_summary"
|
||||
|
||||
var buff bytes.Buffer
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
Summary: true,
|
||||
Stdout: &buff,
|
||||
Stderr: &buff,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "foo"}))
|
||||
assert.Contains(t, buff.String(), "foobar")
|
||||
}
|
||||
|
||||
func TestLabelInStatus(t *testing.T) {
|
||||
const dir = "testdata/label_status"
|
||||
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
err := e.Status(context.Background(), taskfile.Call{Task: "foo"})
|
||||
if assert.Error(t, err) {
|
||||
assert.Contains(t, err.Error(), "foobar")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLabelWithVariableExpansion(t *testing.T) {
|
||||
const dir = "testdata/label_var"
|
||||
|
||||
var buff bytes.Buffer
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
Stdout: &buff,
|
||||
Stderr: &buff,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "foo"}))
|
||||
assert.Contains(t, buff.String(), "foobaz")
|
||||
}
|
||||
|
||||
func TestLabelInSummary(t *testing.T) {
|
||||
const dir = "testdata/label_summary"
|
||||
|
||||
var buff bytes.Buffer
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
Stdout: &buff,
|
||||
Stderr: &buff,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "foo"}))
|
||||
assert.Contains(t, buff.String(), "foobar")
|
||||
}
|
||||
|
||||
func TestLabelInList(t *testing.T) {
|
||||
const dir = "testdata/label_list"
|
||||
|
||||
var buff bytes.Buffer
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
Stdout: &buff,
|
||||
Stderr: &buff,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
e.PrintTasksHelp()
|
||||
assert.Contains(t, buff.String(), "foobar")
|
||||
}
|
||||
|
||||
func TestStatusVariables(t *testing.T) {
|
||||
const dir = "testdata/status_vars"
|
||||
|
||||
|
6
testdata/label_list/Taskfile.yml
vendored
Normal file
6
testdata/label_list/Taskfile.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
foo:
|
||||
label: "foobar"
|
||||
desc: "task description"
|
7
testdata/label_status/Taskfile.yml
vendored
Normal file
7
testdata/label_status/Taskfile.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
foo:
|
||||
label: "foobar"
|
||||
status:
|
||||
- "false"
|
8
testdata/label_summary/Taskfile.yml
vendored
Normal file
8
testdata/label_summary/Taskfile.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
foo:
|
||||
label: "foobar"
|
||||
desc: description
|
||||
status:
|
||||
- echo "I'm ok"
|
7
testdata/label_uptodate/Taskfile.yml
vendored
Normal file
7
testdata/label_uptodate/Taskfile.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
foo:
|
||||
label: "foobar"
|
||||
status:
|
||||
- echo "I'm ok"
|
10
testdata/label_var/Taskfile.yml
vendored
Normal file
10
testdata/label_var/Taskfile.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
BAR: baz
|
||||
|
||||
tasks:
|
||||
foo:
|
||||
label: "foo{{.BAR}}"
|
||||
status:
|
||||
- echo "I'm ok"
|
Loading…
Reference in New Issue
Block a user