mirror of
https://github.com/encounter/go-rtmp.git
synced 2026-03-30 11:12:49 -07:00
40 lines
864 B
Go
40 lines
864 B
Go
//
|
|
// Copyright (c) 2018- yutopp (yutopp@gmail.com)
|
|
//
|
|
// 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 (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestStreams(t *testing.T) {
|
|
b := &rwcMock{}
|
|
conn := newConn(b, &ConnConfig{
|
|
ControlState: StreamControlStateConfig{
|
|
MaxMessageStreams: 1,
|
|
},
|
|
})
|
|
|
|
streams := newStreams(conn)
|
|
|
|
s, err := streams.CreateIfAvailable()
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, uint32(0), s.streamID)
|
|
|
|
// Becomes error because number of max streams is 1
|
|
_, err = streams.CreateIfAvailable()
|
|
assert.NotNil(t, err)
|
|
|
|
err = streams.Delete(s.streamID)
|
|
assert.Nil(t, err)
|
|
|
|
// Becomes error because the stream is already deleted
|
|
err = streams.Delete(s.streamID)
|
|
assert.NotNil(t, err)
|
|
}
|