-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi_test.go
36 lines (32 loc) · 1000 Bytes
/
api_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package streams_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/neutrinocorp/streams"
)
func TestApi(t *testing.T) {
defer func() {
err, ok := recover().(error)
require.True(t, ok)
assert.Equal(t, streams.ErrNilDefaultHub, err)
}()
streams.DefaultHub = streams.NewHub()
streams.RegisterStream(fooEvent{}, streams.StreamMetadata{
Stream: "foo",
})
streams.RegisterStreamByString("", streams.StreamMetadata{})
_ = streams.Read(fooEvent{})
streams.ReadByStreamKey("")
_ = streams.Write(nil, fooEvent{})
_ = streams.WriteByMessageKey(nil, "", fooEvent{})
_, _ = streams.WriteBatch(nil)
_, _ = streams.WriteByMessageKeyBatch(nil, nil)
_ = streams.WriteRawMessage(nil, streams.Message{})
_, _ = streams.WriteRawMessageBatch(nil, streams.Message{})
_ = streams.GetStreamReaderNodes("")
require.Len(t, streams.GetStreamReaderNodes("foo"), 1)
streams.Start(nil)
streams.DefaultHub = nil
_ = streams.Read(nil)
}