mirror of
https://github.com/go-task/task.git
synced 2025-04-21 12:17:07 +02:00
rename to summary in test fixtures
This commit is contained in:
parent
3999480d64
commit
31ecf167cc
2
task.go
2
task.go
@ -85,7 +85,7 @@ func (e *Executor) printTaskSummary(task string) {
|
|||||||
t := e.Taskfile.Tasks[task]
|
t := e.Taskfile.Tasks[task]
|
||||||
s := t.Summary
|
s := t.Summary
|
||||||
if s == "" {
|
if s == "" {
|
||||||
e.Logger.Errf("task: There is no detailed description for task: %s", task)
|
e.Logger.Errf("task: There is no summary for task: %s", task)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
task_test.go
32
task_test.go
@ -554,7 +554,7 @@ func TestIncludesCallingRoot(t *testing.T) {
|
|||||||
tt.Run(t)
|
tt.Run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDetailsParsing(t *testing.T) {
|
func TestSummaryParsing(t *testing.T) {
|
||||||
const dir = "testdata/summary"
|
const dir = "testdata/summary"
|
||||||
|
|
||||||
e := task.Executor{
|
e := task.Executor{
|
||||||
@ -562,12 +562,12 @@ func TestDetailsParsing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.NoError(t, e.Setup())
|
assert.NoError(t, e.Setup())
|
||||||
|
|
||||||
assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Summary, "details of task-with-details - line 1\nline 2\nline 3\n")
|
assert.Equal(t, e.Taskfile.Tasks["task-with-summary"].Summary, "summary of task-with-summary - line 1\nline 2\nline 3\n")
|
||||||
assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Summary, "details of other-task-with-details")
|
assert.Equal(t, e.Taskfile.Tasks["other-task-with-summary"].Summary, "summary of other-task-with-summary")
|
||||||
assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Summary, "")
|
assert.Equal(t, e.Taskfile.Tasks["task-without-summary"].Summary, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDetails(t *testing.T) {
|
func TestSummary(t *testing.T) {
|
||||||
const dir = "testdata/summary"
|
const dir = "testdata/summary"
|
||||||
|
|
||||||
var buff bytes.Buffer
|
var buff bytes.Buffer
|
||||||
@ -579,24 +579,24 @@ func TestDetails(t *testing.T) {
|
|||||||
Silent: true,
|
Silent: true,
|
||||||
}
|
}
|
||||||
assert.NoError(t, e.Setup())
|
assert.NoError(t, e.Setup())
|
||||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"}))
|
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"}))
|
||||||
assert.Equal(t, readTestFixture(t, dir, "task-with-details.txt"), buff.String())
|
assert.Equal(t, readTestFixture(t, dir, "task-with-summary.txt"), buff.String())
|
||||||
|
|
||||||
buff.Reset()
|
buff.Reset()
|
||||||
const noDetails = "task-without-details"
|
const nosummary = "task-without-summary"
|
||||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: noDetails}))
|
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: nosummary}))
|
||||||
assert.Equal(t, "task: There is no detailed description for task: "+noDetails+"\n", buff.String())
|
assert.Equal(t, "task: There is no summary for task: "+nosummary+"\n", buff.String())
|
||||||
|
|
||||||
buff.Reset()
|
buff.Reset()
|
||||||
const firstTask = "other-task-with-details"
|
const firstTask = "other-task-with-summary"
|
||||||
const secondTask = "task-with-details"
|
const secondTask = "task-with-summary"
|
||||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: firstTask}, taskfile.Call{Task: secondTask}))
|
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: firstTask}, taskfile.Call{Task: secondTask}))
|
||||||
assert.Contains(t, buff.String(), "details of "+firstTask)
|
assert.Contains(t, buff.String(), "summary of "+firstTask)
|
||||||
assert.NotContains(t, buff.String(), "details of "+secondTask)
|
assert.NotContains(t, buff.String(), "summary of "+secondTask)
|
||||||
|
|
||||||
buff.Reset()
|
buff.Reset()
|
||||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-description-containing-empty-line"}))
|
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary-containing-empty-line"}))
|
||||||
assert.Equal(t, readTestFixture(t, dir, "task-with-description-containing-empty-line.txt"), buff.String())
|
assert.Equal(t, readTestFixture(t, dir, "task-with-summary-containing-empty-line.txt"), buff.String())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
testdata/summary/Taskfile.yml
vendored
18
testdata/summary/Taskfile.yml
vendored
@ -1,20 +1,20 @@
|
|||||||
version: 2
|
version: 2
|
||||||
tasks:
|
tasks:
|
||||||
task-with-details:
|
task-with-summary:
|
||||||
deps: [dependend-task-1,dependend-task-2]
|
deps: [dependend-task-1,dependend-task-2]
|
||||||
summary: |
|
summary: |
|
||||||
details of task-with-details - line 1
|
summary of task-with-summary - line 1
|
||||||
line 2
|
line 2
|
||||||
line 3
|
line 3
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'task-with-details was executed'
|
- echo 'task-with-summary was executed'
|
||||||
- echo 'another command'
|
- echo 'another command'
|
||||||
- exit 0
|
- exit 0
|
||||||
|
|
||||||
task-without-details:
|
task-without-summary:
|
||||||
deps: [dependend-task]
|
deps: [dependend-task]
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'task-without-details was executed'
|
- echo 'task-without-summary was executed'
|
||||||
|
|
||||||
dependend-task-1:
|
dependend-task-1:
|
||||||
cmds:
|
cmds:
|
||||||
@ -24,12 +24,12 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- echo 'dependend-task-2 was executed'
|
- echo 'dependend-task-2 was executed'
|
||||||
|
|
||||||
other-task-with-details:
|
other-task-with-summary:
|
||||||
summary: details of other-task-with-details
|
summary: summary of other-task-with-summary
|
||||||
cmds:
|
cmds:
|
||||||
- echo 'other-task-with-details was executed'
|
- echo 'other-task-with-summary was executed'
|
||||||
|
|
||||||
task-with-description-containing-empty-line:
|
task-with-summary-containing-empty-line:
|
||||||
summary: |
|
summary: |
|
||||||
First line followed by empty line
|
First line followed by empty line
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
task: task-with-description-containing-empty-line
|
task: task-with-summary-containing-empty-line
|
||||||
|
|
||||||
First line followed by empty line
|
First line followed by empty line
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
task: task-with-details
|
task: task-with-summary
|
||||||
|
|
||||||
details of task-with-details - line 1
|
summary of task-with-summary - line 1
|
||||||
line 2
|
line 2
|
||||||
line 3
|
line 3
|
||||||
|
|
||||||
@ -9,6 +9,6 @@ dependencies:
|
|||||||
- dependend-task-2
|
- dependend-task-2
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
- echo 'task-with-details was executed'
|
- echo 'task-with-summary was executed'
|
||||||
- echo 'another command'
|
- echo 'another command'
|
||||||
- exit 0
|
- exit 0
|
Loading…
x
Reference in New Issue
Block a user