featurebase/ctl/main_test.go
Seebs a6aa1097f1 listen on localhost:0 instead of :0
MacOS's firewall complains about a previously unknown app trying to
listen for network connections whenever we run go test. That's because
we *are* listening for network connections on arbitrary interfaces, not
just on localhost as we probably intended. Fix that.
2022-03-18 13:38:30 -05:00

30 lines
571 B
Go

// Copyright 2021 Molecula Corp. All rights reserved.
package ctl_test
import (
"fmt"
"net"
"net/http"
"testing"
_ "net/http/pprof"
"github.com/molecula/featurebase/v3/testhook"
)
func TestMain(m *testing.M) {
l, err := net.Listen("tcp", "localhost:0")
if err != nil {
panic(err)
}
port := l.Addr().(*net.TCPAddr).Port
fmt.Printf("pilosa/ctl TestMain: online stack-traces: curl http://localhost:%v/debug/pprof/goroutine?debug=2\n", port)
go func() {
err := http.Serve(l, nil)
if err != nil {
panic(err)
}
}()
testhook.RunTestsWithHooks(m)
}