From 4b64fcb8a48f9f8ba78ff89f356be3f9e65e9e9e Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 11:09:55 +0100 Subject: [PATCH] add more tests --- task_test.go | 28 ++++++++++++++++++++++------ testdata/details/Taskfile.yml | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/task_test.go b/task_test.go index ec5af38b..b8e8747b 100644 --- a/task_test.go +++ b/task_test.go @@ -554,6 +554,19 @@ func TestIncludesCallingRoot(t *testing.T) { tt.Run(t) } +func TestDetailsParsing(t *testing.T) { + const dir = "testdata/details" + + e := task.Executor{ + Dir: dir, + } + 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") + assert.Equal(t, e.Taskfile.Tasks["other-task-with-details"].Details, "short details") + assert.Equal(t, e.Taskfile.Tasks["task-without-details"].Details, "") +} + func TestDetails(t *testing.T) { const dir = "testdata/details" @@ -566,19 +579,22 @@ func TestDetails(t *testing.T) { Silent: true, } assert.NoError(t, e.Setup()) - 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, "") + buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) + assert.Contains(t, buff.String(), "This is a very long detailed description") + assert.Contains(t, buff.String(), "with multiple lines") + 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) + buff.Reset() 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") + buff.Reset() + assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "other-task-with-details"}, taskfile.Call{Task: "task-with-details"})) + assert.Contains(t, buff.String(), "details of other-task-with-details") + assert.NotContains(t, buff.String(), "This is a very long detailed description") } diff --git a/testdata/details/Taskfile.yml b/testdata/details/Taskfile.yml index c62300f0..ad84b4fb 100644 --- a/testdata/details/Taskfile.yml +++ b/testdata/details/Taskfile.yml @@ -18,6 +18,6 @@ tasks: - echo 'dependend-task was executed' other-task-with-details: - details: short details + details: details of other-task-with-details cmds: - echo 'other-task-with-details was executed'