diff --git a/cnet/service_test.go b/cnet/service_test.go index 568f2c5..4e07b16 100644 --- a/cnet/service_test.go +++ b/cnet/service_test.go @@ -32,6 +32,7 @@ func TestMain(m *testing.M) { panic(err) } + // this is fine since we don't defer anything os.Exit(m.Run()) } diff --git a/internal/db/db_test.go b/internal/db/db_test.go index 771bf46..4ab1401 100644 --- a/internal/db/db_test.go +++ b/internal/db/db_test.go @@ -18,6 +18,11 @@ var ( ) func TestMain(m *testing.M) { + ret := 1 + defer func() { + os.Exit(ret) + }() + ctx := context.Background() psql, err := sqltestutil.StartPostgresContainer(ctx, "15") if err != nil { @@ -35,7 +40,7 @@ func TestMain(m *testing.M) { panic(err) } - os.Exit(m.Run()) + ret = m.Run() } func TestDBAccount(t *testing.T) { diff --git a/internal/redis/redis_test.go b/internal/redis/redis_test.go index 2bee4c2..fd63aa1 100644 --- a/internal/redis/redis_test.go +++ b/internal/redis/redis_test.go @@ -14,6 +14,11 @@ var ( ) func TestMain(m *testing.M) { + ret := 1 + defer func() { + os.Exit(ret) + }() + r, err := miniredis.Run() if err != nil { panic(err) @@ -26,7 +31,7 @@ func TestMain(m *testing.M) { } defer rh.Close() - os.Exit(m.Run()) + ret = m.Run() } func TestRedisLogin(t *testing.T) { diff --git a/login/login_test.go b/login/login_test.go index e250f0b..bfa8fd8 100644 --- a/login/login_test.go +++ b/login/login_test.go @@ -22,6 +22,11 @@ var ( rh *redis.RedisHandler ) +/* +test data was scraped by dumping packets, just adding a println to the LoginService +to print the packet data +*/ + var ( testCharCreate = protocol.SP_CL2LS_REQ_CHAR_CREATE{ PCStyle: protocol.SPCStyle{ @@ -42,6 +47,11 @@ var ( ) func TestMain(m *testing.M) { + ret := 1 + defer func() { + os.Exit(ret) + }() + ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -70,10 +80,9 @@ func TestMain(m *testing.M) { // wait for login server to start, then start tests <-loginSrv.Service().Started() - ret := m.Run() + ret = m.Run() cancel() <-loginSrv.Service().Stopped() - os.Exit(ret) } // This test tries a typical login sequence.