Skip to content

Commit ad3b00e

Browse files
authored
Random tests (#308)
1 parent a24c4a2 commit ad3b00e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2827
-4754
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
uses: golangci/[email protected]
1919
with:
2020
version: v1.29
21-
- name: Test
22-
run: go clean -testcache ./... && go test -race -timeout 10s ./...
21+
- name: test
22+
run: make test

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test:
2+
go clean -testcache ./...
3+
go test -race -timeout 10s ./... --tags=all
4+
go test -timeout 10s -run TestLeak

factory.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// to emit an item or notification.
1313
func Amb(observables []Observable, opts ...Option) Observable {
1414
option := parseOptions(opts...)
15-
ctx := option.buildContext()
15+
ctx := option.buildContext(emptyContext)
1616
next := option.buildChannel()
1717
once := sync.Once{}
1818

@@ -65,7 +65,7 @@ func Amb(observables []Observable, opts ...Option) Observable {
6565
// and emit items based on the results of this function.
6666
func CombineLatest(f FuncN, observables []Observable, opts ...Option) Observable {
6767
option := parseOptions(opts...)
68-
ctx := option.buildContext()
68+
ctx := option.buildContext(emptyContext)
6969
next := option.buildChannel()
7070

7171
go func() {
@@ -130,7 +130,7 @@ func CombineLatest(f FuncN, observables []Observable, opts ...Option) Observable
130130
// Concat emits the emissions from two or more Observables without interleaving them.
131131
func Concat(observables []Observable, opts ...Option) Observable {
132132
option := parseOptions(opts...)
133-
ctx := option.buildContext()
133+
ctx := option.buildContext(emptyContext)
134134
next := option.buildChannel()
135135

136136
go func() {
@@ -186,7 +186,10 @@ func Empty() Observable {
186186

187187
// FromChannel creates a cold observable from a channel.
188188
func FromChannel(next <-chan Item, opts ...Option) Observable {
189+
option := parseOptions(opts...)
190+
ctx := option.buildContext(emptyContext)
189191
return &ObservableImpl{
192+
parent: ctx,
190193
iterable: newChannelIterable(next, opts...),
191194
}
192195
}
@@ -196,7 +199,7 @@ func FromEventSource(next <-chan Item, opts ...Option) Observable {
196199
option := parseOptions(opts...)
197200

198201
return &ObservableImpl{
199-
iterable: newEventSourceIterable(option.buildContext(), next, option.getBackPressureStrategy()),
202+
iterable: newEventSourceIterable(option.buildContext(emptyContext), next, option.getBackPressureStrategy()),
200203
}
201204
}
202205

@@ -205,7 +208,7 @@ func FromEventSource(next <-chan Item, opts ...Option) Observable {
205208
func Interval(interval Duration, opts ...Option) Observable {
206209
option := parseOptions(opts...)
207210
next := option.buildChannel()
208-
ctx := option.buildContext()
211+
ctx := option.buildContext(emptyContext)
209212

210213
go func() {
211214
i := 0
@@ -246,7 +249,7 @@ func JustItem(item interface{}, opts ...Option) Single {
246249
// Merge combines multiple Observables into one by merging their emissions
247250
func Merge(observables []Observable, opts ...Option) Observable {
248251
option := parseOptions(opts...)
249-
ctx := option.buildContext()
252+
ctx := option.buildContext(emptyContext)
250253
next := option.buildChannel()
251254
wg := sync.WaitGroup{}
252255
wg.Add(len(observables))
@@ -311,7 +314,7 @@ func Range(start, count int, opts ...Option) Observable {
311314
func Start(fs []Supplier, opts ...Option) Observable {
312315
option := parseOptions(opts...)
313316
next := option.buildChannel()
314-
ctx := option.buildContext()
317+
ctx := option.buildContext(emptyContext)
315318

316319
go func() {
317320
defer close(next)
@@ -343,7 +346,7 @@ func Thrown(err error) Observable {
343346
func Timer(d Duration, opts ...Option) Observable {
344347
option := parseOptions(opts...)
345348
next := make(chan Item, 1)
346-
ctx := option.buildContext()
349+
ctx := option.buildContext(emptyContext)
347350

348351
go func() {
349352
defer close(next)

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ module github.com/reactivex/rxgo/v2
33
go 1.13
44

55
require (
6-
github.com/cenkalti/backoff/v4 v4.1.0
6+
github.com/cenkalti/backoff/v4 v4.0.0
77
github.com/emirpasic/gods v1.12.0
8-
github.com/stretchr/testify v1.7.0
8+
github.com/stretchr/testify v1.4.0
9+
github.com/teivah/onecontext v0.0.0-20200513185103-40f981bfd775
910
go.uber.org/goleak v1.1.10
1011
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
1112
)

go.sum

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/cenkalti/backoff/v4 v4.1.0 h1:c8LkOFQTzuO0WBM/ae5HdGQuZPfPxp7lqBRwQRm4fSc=
2-
github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
1+
github.com/cenkalti/backoff/v4 v4.0.0 h1:6VeaLF9aI+MAUQ95106HwWzYZgJJpZ4stumjj6RFYAU=
2+
github.com/cenkalti/backoff/v4 v4.0.0/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
33
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
44
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
@@ -13,9 +13,11 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1313
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1414
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
1515
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
16+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
17+
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
1618
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
17-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
18-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
19+
github.com/teivah/onecontext v0.0.0-20200513185103-40f981bfd775 h1:BLNsFR8l/hj/oGjnJXkd4Vi3s4kQD3/3x8HSAE4bzN0=
20+
github.com/teivah/onecontext v0.0.0-20200513185103-40f981bfd775/go.mod h1:XUZ4x3oGhWfiOnUvTslnKKs39AWUct3g3yJvXTQSJOQ=
1921
go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
2022
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
2123
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -32,9 +34,9 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
3234
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E=
3335
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
3436
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
37+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3538
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3639
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
3740
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
41+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
3842
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
39-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
40-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

iterable_channel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (i *channelIterable) Observe(opts ...Option) <-chan Item {
3030
}
3131

3232
if option.isConnectOperation() {
33-
i.connect(option.buildContext())
33+
i.connect(option.buildContext(emptyContext))
3434
return nil
3535
}
3636

iterable_create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type createIterable struct {
1616
func newCreateIterable(fs []Producer, opts ...Option) Iterable {
1717
option := parseOptions(opts...)
1818
next := option.buildChannel()
19-
ctx := option.buildContext()
19+
ctx := option.buildContext(emptyContext)
2020

2121
go func() {
2222
defer close(next)
@@ -40,7 +40,7 @@ func (i *createIterable) Observe(opts ...Option) <-chan Item {
4040
}
4141

4242
if option.isConnectOperation() {
43-
i.connect(option.buildContext())
43+
i.connect(option.buildContext(emptyContext))
4444
return nil
4545
}
4646

iterable_defer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func newDeferIterable(f []Producer, opts ...Option) Iterable {
1515
func (i *deferIterable) Observe(opts ...Option) <-chan Item {
1616
option := parseOptions(append(i.opts, opts...)...)
1717
next := option.buildChannel()
18-
ctx := option.buildContext()
18+
ctx := option.buildContext(emptyContext)
1919

2020
go func() {
2121
defer close(next)

iterable_just.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ func (i *justIterable) Observe(opts ...Option) <-chan Item {
1818
option := parseOptions(append(i.opts, opts...)...)
1919
next := option.buildChannel()
2020

21-
go SendItems(option.buildContext(), next, CloseChannel, i.items)
21+
go SendItems(option.buildContext(emptyContext), next, CloseChannel, i.items)
2222
return next
2323
}

iterable_range.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func newRangeIterable(start, count int, opts ...Option) Iterable {
1515

1616
func (i *rangeIterable) Observe(opts ...Option) <-chan Item {
1717
option := parseOptions(append(i.opts, opts...)...)
18-
ctx := option.buildContext()
18+
ctx := option.buildContext(emptyContext)
1919
next := option.buildChannel()
2020

2121
go func() {

0 commit comments

Comments
 (0)