Files
go-rtmp/server_test.go
T
2018-08-09 17:27:56 +09:00

32 lines
613 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"
"net"
"testing"
"time"
)
func TestServerCanClose(t *testing.T) {
srv := NewServer(&ServerConfig{})
go func(ch <-chan time.Time) {
<-ch
err := srv.Close()
assert.Nil(t, err)
}(time.After(1 * time.Second))
l, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
err = srv.Serve(l)
assert.Equal(t, ErrClosed, err)
}