fix: speed up tests and reduce output verbosity
All checks were successful
check / check (push) Successful in 58s
All checks were successful
check / check (push) Successful in 58s
- Use bcrypt.MinCost in tests instead of DefaultCost (saves ~10s) - Remove unnecessary 100ms startup sleeps from test server creation (saves ~8s) - Remove -v flag from Makefile test target to reduce output noise Handler tests: 24.4s → 13.8s, DB tests: 2.6s → 1.5s Total make test: 38s → 28s (well under 30s timeout)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -30,8 +31,14 @@ import (
|
||||
"git.eeqj.de/sneak/neoirc/internal/stats"
|
||||
"go.uber.org/fx"
|
||||
"go.uber.org/fx/fxtest"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
db.SetBcryptCost(bcrypt.MinCost)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
const (
|
||||
commandKey = "command"
|
||||
bodyKey = "body"
|
||||
@@ -102,7 +109,6 @@ func newTestServer(
|
||||
)
|
||||
|
||||
app.RequireStart()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
httpSrv := httptest.NewServer(srv)
|
||||
|
||||
@@ -2985,10 +2991,7 @@ func newTestServerWithOper(
|
||||
fx.Populate(&srv),
|
||||
)
|
||||
|
||||
const startupDelay = 100 * time.Millisecond
|
||||
|
||||
app.RequireStart()
|
||||
time.Sleep(startupDelay)
|
||||
|
||||
httpSrv := httptest.NewServer(srv)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user