1package interactors
2
3import (
4	"testing"
5
6	"github.com/pkg/errors"
7	"github.com/stretchr/testify/assert"
8)
9
10func funcWithErr() error {
11	return errors.New("This is a private residence, man")
12}
13
14func funcNoErr() error {
15	return nil
16}
17
18func TestExecuteFunctionsAsyncErrExists(t *testing.T) {
19	err := NewTaskRunner().ExecuteFunctionsAsync(
20		[]func() error{
21			funcNoErr,
22			funcWithErr,
23			funcNoErr,
24		},
25	)
26	assert.NotEqual(t, nil, err, "Error should exist")
27}
28
29func TestExecuteFunctionsAsyncNoErr(t *testing.T) {
30	err := NewTaskRunner().ExecuteFunctionsAsync(
31		[]func() error{
32			funcNoErr,
33			funcNoErr,
34			funcNoErr,
35		},
36	)
37	assert.Equal(t, nil, err, "Error should not exist")
38}
39