generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ddd6db
commit 0937cae
Showing
3 changed files
with
84 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package rx_test | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/fortytw2/leaktest" | ||
. "github.com/onsi/ginkgo/v2" //nolint:revive // ginkgo ok | ||
. "github.com/onsi/gomega" //nolint:revive // gomega ok | ||
) | ||
|
||
var _ = Describe("Observable operator", func() { | ||
Context("Run", func() { | ||
When("principle", func() { | ||
It("🧪 should: ", func() { | ||
// rxgo: Test_Observable_Run | ||
defer leaktest.Check(GinkgoT())() | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
s := make([]int, 0) | ||
<-testObservable[int](ctx, 1, 2, 3).Map( | ||
func(_ context.Context, i int) (int, error) { | ||
s = append(s, i) | ||
|
||
return i, nil | ||
}, | ||
).Run() | ||
|
||
Expect(s).To(ContainElements([]int{1, 2, 3})) | ||
}) | ||
}) | ||
|
||
Context("Errors", func() { | ||
When("error", func() { | ||
It("🧪 should: ", func() { | ||
// rxgo: Test_Observable_Run_Error | ||
defer leaktest.Check(GinkgoT())() | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
s := make([]int, 0) | ||
<-testObservable[int](ctx, 1, errFoo).Map( | ||
func(_ context.Context, i int) (int, error) { | ||
s = append(s, i) | ||
|
||
return i, nil | ||
}, | ||
).Run() | ||
|
||
Expect(s).To(ContainElements([]int{1})) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters