浏览代码

Merge pull request #33522 from naveed-jamil-tenpearls/pkg/promise

Added Test Case Coverage for PKG/PROMISE
Sebastiaan van Stijn 8 年之前
父节点
当前提交
16380b3ee6
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      pkg/promise/promise_test.go

+ 25 - 0
pkg/promise/promise_test.go

@@ -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
+}