From 76253bf516b2009c5889bbddaee6dec6744d1408 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 5 Aug 2018 12:56:55 -0300 Subject: [PATCH] Reduce code duplication on test --- task_test.go | 48 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/task_test.go b/task_test.go index d38e4f61..58687cab 100644 --- a/task_test.go +++ b/task_test.go @@ -416,45 +416,17 @@ func TestTaskVersion(t *testing.T) { func TestTaskIgnoreErrors(t *testing.T) { const dir = "testdata/ignore_errors" - t.Run("task-should-pass", func(t *testing.T) { - e := task.Executor{ - Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, - } - assert.NoError(t, e.Setup()) - assert.NoError(t, e.Run(taskfile.Call{Task: "task-should-pass"})) - }) + e := task.Executor{ + Dir: dir, + Stdout: ioutil.Discard, + Stderr: ioutil.Discard, + } + assert.NoError(t, e.Setup()) - t.Run("task-should-fail", func(t *testing.T) { - e := task.Executor{ - Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, - } - assert.NoError(t, e.Setup()) - assert.Error(t, e.Run(taskfile.Call{Task: "task-should-fail"})) - }) - - t.Run("cmd-should-pass", func(t *testing.T) { - e := task.Executor{ - Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, - } - assert.NoError(t, e.Setup()) - assert.NoError(t, e.Run(taskfile.Call{Task: "cmd-should-pass"})) - }) - - t.Run("cmd-should-fail", func(t *testing.T) { - e := task.Executor{ - Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, - } - assert.NoError(t, e.Setup()) - assert.Error(t, e.Run(taskfile.Call{Task: "cmd-should-fail"})) - }) + assert.NoError(t, e.Run(taskfile.Call{Task: "task-should-pass"})) + assert.Error(t, e.Run(taskfile.Call{Task: "task-should-fail"})) + assert.NoError(t, e.Run(taskfile.Call{Task: "cmd-should-pass"})) + assert.Error(t, e.Run(taskfile.Call{Task: "cmd-should-fail"})) } func TestExpand(t *testing.T) {