From 8cf194cb9cf9c37cb6375c6632cf3c556004c3e7 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 6 Apr 2024 18:33:43 +0700 Subject: all: fix flaky test due to test test server is not ready In TestMain we run dummy server to test the client. Sometimes when test running the server has not ready yet. To fix this we check if the server is ready using [libnet.WaitAlive]. --- kamusd_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kamusd_test.go b/kamusd_test.go index 667dc09..62cd9ed 100644 --- a/kamusd_test.go +++ b/kamusd_test.go @@ -7,8 +7,10 @@ import ( "log" "os" "testing" + "time" "git.sr.ht/~shulhan/kamusku" + libnet "git.sr.ht/~shulhan/pakakeh.go/lib/net" ) const ( @@ -50,5 +52,10 @@ func TestMain(m *testing.M) { } }() + err = libnet.WaitAlive(`tcp`, `127.0.0.1`+defListen, 3*time.Second) + if err != nil { + log.Fatal(err) + } + os.Exit(m.Run()) } -- cgit v1.3