From a951f2403d11df8ea77b4173c4582b88d13037e4 Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:01:48 +0100 Subject: [PATCH] add more tests for details --- task_test.go | 16 +++++++++++++++- testdata/details/Taskfile.yml | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/task_test.go b/task_test.go index 707f0223..ec5af38b 100644 --- a/task_test.go +++ b/task_test.go @@ -563,8 +563,22 @@ func TestDetails(t *testing.T) { Stdout: &buff, Stderr: &buff, Details: true, + Silent: true, } assert.NoError(t, e.Setup()) - assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, "This is a very long detailed description\nwith multiple lines\n") + const longDetails = "This is a very long detailed description\nwith multiple lines\n" + assert.Equal(t, e.Taskfile.Tasks["task-with-details"].Details, longDetails) + const shortDetails = "short details" + assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, shortDetails) assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") + + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) + assert.NotContains(t, buff.String(), "task-with-details was executed") + assert.NotContains(t, buff.String(), "dependend-task was executed") + assert.Contains(t, buff.String(), longDetails) + + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-details"})) + assert.NotContains(t, buff.String(), "task-without-details was executed") + assert.NotContains(t, buff.String(), "dependend-task was executed") + } diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index e8bcb9d3..c62300f0 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -1,12 +1,23 @@ version: 2 tasks: task-with-details: + deps: [dependend-task] details: | This is a very long detailed description with multiple lines cmds: - - exit 0 + - echo 'task-with-details was executed' task-without-details: + deps: [dependend-task] cmds: - - exit 0 + - echo 'task-without-details was executed' + + dependend-task: + cmds: + - echo 'dependend-task was executed' + + other-task-with-details: + details: short details + cmds: + - echo 'other-task-with-details was executed'