-
Notifications
You must be signed in to change notification settings - Fork 86
/
streams_test.go
40 lines (31 loc) · 871 Bytes
/
streams_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
37
38
39
40
//
// Copyright (c) 2018- yutopp ([email protected])
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
package rtmp
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestStreams(t *testing.T) {
b := &rwcMock{}
conn := newConn(b, &ConnConfig{
ControlState: StreamControlStateConfig{
MaxMessageStreams: 1,
},
})
streams := newStreams(conn)
s, err := streams.CreateIfAvailable()
require.Nil(t, err)
require.Equal(t, uint32(0), s.streamID)
// Becomes error because number of max streams is 1
_, err = streams.CreateIfAvailable()
require.NotNil(t, err)
err = streams.Delete(s.streamID)
require.Nil(t, err)
// Becomes error because the stream is already deleted
err = streams.Delete(s.streamID)
require.NotNil(t, err)
}