summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-04-06 18:33:43 +0700
committerShulhan <ms@kilabit.info>2024-04-06 19:28:53 +0700
commit8cf194cb9cf9c37cb6375c6632cf3c556004c3e7 (patch)
tree14f65c471a2a34ef9dddc84f85c6e18fc9453bb6
parentdef8f703c311acedc77310557f3363eee2de7957 (diff)
downloadkamusku-8cf194cb9cf9c37cb6375c6632cf3c556004c3e7.tar.xz
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].
-rw-r--r--kamusd_test.go7
1 files changed, 7 insertions, 0 deletions
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())
}