mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #33522 from naveed-jamil-tenpearls/pkg/promise
Added Test Case Coverage for PKG/PROMISE
This commit is contained in:
commit
16380b3ee6
1 changed files with 25 additions and 0 deletions
25
pkg/promise/promise_test.go
Normal file
25
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
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue