dospin/net_test.go

28 lines
644 B
Go
Raw Normal View History

2016-02-27 18:15:37 -06:00
/*
2017-01-25 17:59:25 -06:00
Copyright 2016-2017 gtalent2@gmail.com
2016-02-27 18:15:37 -06:00
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package main
import (
"net"
"strconv"
"testing"
)
func TestPortCount(t *testing.T) {
port := 49214
// listen on some port that nothing should be using for the sake of the test
go func() {
addr, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:"+strconv.Itoa(port))
net.ListenTCP("tcp", addr)
}()
if portUsageCount(49214) != 1 {
t.Errorf("Port count usage reporting wrong number")
}
}