You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
naza/pkg/mockserver/mockserver_test.go

50 lines
1.0 KiB
Go

// Copyright 2019, Chef. All rights reserved.
// https://github.com/q191201771/naza
//
// Use of this source code is governed by a MIT-style license
// that can be found in the License file.
//
// Author: Chef (191201771@qq.com)
package mockserver
import (
"net"
"testing"
"time"
"github.com/q191201771/naza/pkg/assert"
)
var addr = ":10027"
func TestMockListenServer(t *testing.T) {
//var s MockListenServer
//err := s.Run(addr)
//assert.Equal(t, nil, err)
//defer s.Dispose()
//_, err = net.DialTimeout("tcp", addr, time.Duration(1000) * time.Millisecond)
//assert.IsNotNil(t, err)
}
func TestMockAcceptServer(t *testing.T) {
var s MockAcceptServer
var conns []net.Conn
go s.Run(addr)
for i := 0; i < 16; i++ {
c, err := net.DialTimeout("tcp", addr, time.Duration(1000)*time.Millisecond)
if err != nil {
break
}
//assert.Equal(t, nil, err)
conns = append(conns, c)
}
s.Dispose()
}
func TestCorner(t *testing.T) {
var s MockListenServer
err := s.Run("wrong addr")
assert.IsNotNil(t, err)
}