Added Test Case Coverage for PKG/PROMISE
Signed-off-by: Naveed Jamil <naveed.jamil@tenpearls.com> Upstream-commit: cffa6d52a2819c126517333b8b31337ded5cc0d9 Component: engine
This commit is contained in:
25
components/engine/pkg/promise/promise_test.go
Normal file
25
components/engine/pkg/promise/promise_test.go
Normal file
@ -0,0 +1,25 @@
|
||||
package promise
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGo(t *testing.T) {
|
||||
errCh := Go(functionWithError)
|
||||
er := <-errCh
|
||||
require.EqualValues(t, "Error Occurred", er.Error())
|
||||
|
||||
noErrCh := Go(functionWithNoError)
|
||||
er = <-noErrCh
|
||||
require.Nil(t, er)
|
||||
}
|
||||
|
||||
func functionWithError() (err error) {
|
||||
return errors.New("Error Occurred")
|
||||
}
|
||||
func functionWithNoError() (err error) {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user