diff options
| author | Shulhan <ms@kilabit.info> | 2024-04-06 18:33:43 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-04-06 19:28:53 +0700 |
| commit | 8cf194cb9cf9c37cb6375c6632cf3c556004c3e7 (patch) | |
| tree | 14f65c471a2a34ef9dddc84f85c6e18fc9453bb6 /kamusd_test.go | |
| parent | def8f703c311acedc77310557f3363eee2de7957 (diff) | |
| download | kamusku-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].
Diffstat (limited to 'kamusd_test.go')
| -rw-r--r-- | kamusd_test.go | 7 |
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()) } |
