featurebase/sql/main_test.go
Seebs 331b5a0e36 use testhook test cleanup
The testhook post-test hooks only work if you use a TestMain to
invoke them, otherwise the cleanups can be registered but never
actually get run. This deletes the etcd sockets, and temp
directories, that we created from our test runs. We also fix
the test creating a temp file directly to create it in a TempDir
(which gets cleaned up after the test), and fix the name of the
top-level tests displayed in TestMain.
2022-09-30 11:25:27 -07:00

30 lines
565 B
Go

// Copyright 2021 Molecula Corp. All rights reserved.
package sql_test
import (
"fmt"
"net"
"testing"
"net/http"
_ "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("sql/ 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)
}