Skip to content

Commit 518d40c

Browse files
committed
refactor: rename testing pacakge to rotesting
1 parent 62e0363 commit 518d40c

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

docs/docs/testing.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The testing framework is designed to be intuitive and expressive, allowing you t
1515
The testing functionality is available in the `/testing` package:
1616

1717
```go
18-
import "github.com/samber/ro/testing"
18+
import rotesting "github.com/samber/ro/testing"
1919
```
2020

2121
## Basic Usage
@@ -28,13 +28,13 @@ The fluent API makes it easy to verify exact sequences of values. Each expectati
2828
import (
2929
"testing"
3030
"github.com/samber/ro"
31-
"github.com/samber/ro/testing"
31+
rotesting "github.com/samber/ro/testing"
3232
)
3333

3434
func TestObservable(t *testing.T) {
3535
observable := ro.Just(1, 2, 3)
3636

37-
testing.Assert[int](t).
37+
rorotesting.Assert[int](t).
3838
Source(observable).
3939
ExpectNext(1).
4040
ExpectNext(2).
@@ -66,7 +66,7 @@ var pipeline = ro.PipeOp3(
6666
func TestObservable(t *testing.T) {
6767
observable := pipeline(ro.Just(1, 2, 3, 4))
6868

69-
testing.Assert[string](t).
69+
rotesting.Assert[string](t).
7070
Source(observable).
7171
ExpectNext("processed-1").
7272
ExpectNext("processed-3").
@@ -83,7 +83,7 @@ Test error scenarios by creating observables that emit specific errors and verif
8383
func TestObservableError(t *testing.T) {
8484
observable := ro.Throw[string](errors.New("something went wrong"))
8585

86-
testing.Assert[string](t).
86+
rotesting.Assert[string](t).
8787
Source(observable).
8888
ExpectError(errors.New("something went wrong")).
8989
Verify()
@@ -98,7 +98,7 @@ Use `ExpectNextSeq()` to verify multiple values at once. This is more concise th
9898
func TestObservableSequence(t *testing.T) {
9999
observable := ro.Range(1, 5)
100100

101-
testing.Assert[int](t).
101+
rotesting.Assert[int](t).
102102
Source(observable).
103103
ExpectNextSeq(1, 2, 3, 4, 5).
104104
ExpectComplete().
@@ -163,7 +163,7 @@ func TestObservableWithContext(t *testing.T) {
163163
ro.Take(3),
164164
)
165165

166-
testing.Assert[int](t).
166+
rotesting.Assert[int](t).
167167
Source(observable).
168168
ExpectNextSeq(0, 1, 2).
169169
ExpectComplete().
@@ -179,7 +179,7 @@ Custom error messages make test failures easier to debug. When assertions fail,
179179
func TestObservableWithCustomMessages(t *testing.T) {
180180
observable := ro.Just("hello", "world")
181181

182-
testing.Assert[string](t).
182+
rotesting.Assert[string](t).
183183
Source(observable).
184184
ExpectNext("hello", "expected first value to be 'hello'").
185185
ExpectNext("world", "expected second value to be 'world'").
@@ -203,7 +203,7 @@ func TestHotObservable(t *testing.T) {
203203
subject.Complete()
204204
}()
205205

206-
testing.Assert[int](t).
206+
rotesting.Assert[int](t).
207207
Source(subject).
208208
ExpectNextSeq(1, 2).
209209
ExpectComplete().

plugins/testify/testify.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020

2121
"github.com/samber/lo"
2222
"github.com/samber/ro"
23-
"github.com/samber/ro/testing"
23+
rotesting "github.com/samber/ro/testing"
2424
"github.com/stretchr/testify/assert"
2525
)
2626

@@ -39,7 +39,7 @@ type testifyAssertion[T any] struct {
3939
// observable sequence.
4040
//
4141
// Inspired by Flux.
42-
func Testify[T any](is *assert.Assertions) testing.AssertSpec[T] {
42+
func Testify[T any](is *assert.Assertions) rotesting.AssertSpec[T] {
4343
return &testify[T]{
4444
is: is,
4545
assertions: []testifyAssertion[T]{},
@@ -66,15 +66,15 @@ func (t *testify[T]) hasErrorOrCompletionNotification() bool {
6666
}
6767

6868
// Source sets the source observable for the test.
69-
func (t *testify[T]) Source(source ro.Observable[T]) testing.AssertSpec[T] {
69+
func (t *testify[T]) Source(source ro.Observable[T]) rotesting.AssertSpec[T] {
7070
t.source = source
7171
return t
7272
}
7373

7474
// ExpectNext expects the next value to be emitted by the source observable.
7575
// It fails the test if the next value is not emitted. If the source observable
7676
// emits an error or completes, it fails the test.
77-
func (t *testify[T]) ExpectNext(value T, msgAndArgs ...any) testing.AssertSpec[T] {
77+
func (t *testify[T]) ExpectNext(value T, msgAndArgs ...any) rotesting.AssertSpec[T] {
7878
assertion := testifyAssertion[T]{
7979
notification: ro.NewNotificationNext(value),
8080
msgAndArgs: msgAndArgs,
@@ -86,7 +86,7 @@ func (t *testify[T]) ExpectNext(value T, msgAndArgs ...any) testing.AssertSpec[T
8686
// ExpectNextSeq expects the next values to be emitted by the source observable.
8787
// It fails the test if the next values are not emitted. If the source observable
8888
// emits an error or completes, it fails the test.
89-
func (t *testify[T]) ExpectNextSeq(values ...T) testing.AssertSpec[T] {
89+
func (t *testify[T]) ExpectNextSeq(values ...T) rotesting.AssertSpec[T] {
9090
for i := range values {
9191
assertion := testifyAssertion[T]{
9292
notification: ro.NewNotificationNext(values[i]),
@@ -101,7 +101,7 @@ func (t *testify[T]) ExpectNextSeq(values ...T) testing.AssertSpec[T] {
101101
// if the source observable emits a value or completes. If the source observable
102102
// emits an error, it compares the error with the expected error. If the error
103103
// is not equal to the expected error, it fails the test.
104-
func (t *testify[T]) ExpectError(err error, msgAndArgs ...any) testing.AssertSpec[T] {
104+
func (t *testify[T]) ExpectError(err error, msgAndArgs ...any) rotesting.AssertSpec[T] {
105105
if t.hasErrorOrCompletionNotification() {
106106
t.is.Fail("cannot have multiple error or completion notifications")
107107
}
@@ -116,7 +116,7 @@ func (t *testify[T]) ExpectError(err error, msgAndArgs ...any) testing.AssertSpe
116116

117117
// ExpectComplete expects the source observable to complete. It fails the test
118118
// if the source observable emits a value or an error.
119-
func (t *testify[T]) ExpectComplete(msgAndArgs ...any) testing.AssertSpec[T] {
119+
func (t *testify[T]) ExpectComplete(msgAndArgs ...any) rotesting.AssertSpec[T] {
120120
if t.hasErrorOrCompletionNotification() {
121121
t.is.Fail("cannot have multiple error or completion notifications")
122122
}

testing/assert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package testing
15+
package rotesting
1616

1717
import (
1818
"context"

testing/assert_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package testing
15+
package rotesting
1616

1717
import (
1818
"testing"

testing/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package testing
15+
package rotesting
1616

1717
import (
1818
"context"

0 commit comments

Comments
 (0)