Skip to content

Commit fe82b70

Browse files
author
Piotr
committed
udpates to tests
1 parent 6d4ee39 commit fe82b70

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/socket_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ func TestLogdyE2E_Socket(t *testing.T) {
1919

2020
// Setup wait group for message sending
2121
var wg sync.WaitGroup
22+
var wgReady sync.WaitGroup
23+
wgReady.Add(1)
2224
wg.Add(3) // Expect 3 messages (1 from each port)
2325

2426
// Start logdy process with -t flag for stdout output
2527
cmd := exec.Command("go", "run", "../main.go", "socket", "-t", "8475", "8476", "8477")
26-
2728
// Get stdout pipe for verifying messages
2829
stdout, err := cmd.StdoutPipe()
2930
assert.NoError(t, err)
@@ -33,6 +34,9 @@ func TestLogdyE2E_Socket(t *testing.T) {
3334
scanner := bufio.NewScanner(stdout)
3435
for scanner.Scan() {
3536
line := scanner.Text()
37+
if strings.Contains(line, `WebUI started`) {
38+
wgReady.Done()
39+
}
3640
select {
3741
case msgChan <- line:
3842
// Message sent to channel
@@ -47,7 +51,8 @@ func TestLogdyE2E_Socket(t *testing.T) {
4751
assert.NoError(t, err)
4852

4953
// Give the process more time to start up and initialize all socket servers
50-
time.Sleep(2 * time.Second)
54+
wgReady.Wait()
55+
time.Sleep(1 * time.Second)
5156

5257
// Send test messages to each port
5358
ports := []string{"8475", "8476", "8477"}
@@ -59,7 +64,7 @@ func TestLogdyE2E_Socket(t *testing.T) {
5964
if err == nil {
6065
break
6166
}
62-
time.Sleep(100 * time.Millisecond)
67+
time.Sleep(1 * time.Millisecond)
6368
}
6469
assert.NoError(t, err, "Failed to connect to port %s after retries", port)
6570

0 commit comments

Comments
 (0)