From 5cfd9bbbbdd0c65a1e0814db25756fb341dc717d Mon Sep 17 00:00:00 2001 From: jaedle Date: Sun, 24 Feb 2019 17:25:03 +0100 Subject: [PATCH] refactoring --- internal/summary/summary.go | 3 ++- internal/summary/summary_test.go | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/internal/summary/summary.go b/internal/summary/summary.go index df864823..db5476cf 100644 --- a/internal/summary/summary.go +++ b/internal/summary/summary.go @@ -24,7 +24,8 @@ func printTaskCommands(cmds []*taskfile.Cmd, logger *logger.Logger) { logger.Outf("") logger.Outf("commands:") for _, c := range cmds { - if c.Cmd != "" { + isCommand := c.Cmd != "" + if isCommand { logger.Outf(" - %s", c.Cmd) } else { logger.Outf(" - Task: %s", c.Task) diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go index b64e1c7f..6191cca6 100644 --- a/internal/summary/summary_test.go +++ b/internal/summary/summary_test.go @@ -123,19 +123,22 @@ func TestFullSummary(t *testing.T) { summary.Print(&l, task) + assert.Equal(t, expectedOutput(), buffer.String()) +} + +func expectedOutput() string { expected := `task: sample-task - -line1 -line2 -line3 - -dependencies: - - dependency - -commands: - - command -` - - assert.Equal(t, expected, buffer.String()) + + line1 + line2 + line3 + + dependencies: + - dependency + + commands: + - command + ` + return expected }