Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
837275fa92 |
@@ -4,8 +4,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -361,8 +359,7 @@ func TestLinesKeepOrder(t *testing.T) {
|
||||
|
||||
// TestStartUp runs the client's start-up path on a simulation
|
||||
// screen. It fails unless the event loop starts and the status
|
||||
// window gets two lines: first the one that holds "Welcome to
|
||||
// neoirc-cli", then the /connect hint.
|
||||
// window gets the welcome lines.
|
||||
func TestStartUp(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -389,22 +386,16 @@ func TestStartUp(t *testing.T) {
|
||||
})
|
||||
|
||||
// run adds the welcome lines on a goroutine, so the status
|
||||
// window is read until it holds two lines. Each read waits for
|
||||
// window is read until they are there. Each read waits for
|
||||
// the event loop, so the reads run on a goroutine too, which
|
||||
// this test stops waiting for after eventLoopTimeout. The
|
||||
// channel has one slot, so that goroutine can still end.
|
||||
shown := make(chan []string, 1)
|
||||
// this test stops waiting for after eventLoopTimeout.
|
||||
shown := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
for {
|
||||
var lines []string
|
||||
|
||||
ui.app.QueueUpdate(func() {
|
||||
lines = slices.Clone(ui.getOrCreateBuffer("(status)").Lines)
|
||||
})
|
||||
|
||||
if len(lines) == welcomeLines {
|
||||
shown <- lines
|
||||
lines, _ := bufferState(ui, "(status)")
|
||||
if lines == welcomeLines {
|
||||
close(shown)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -413,22 +404,12 @@ func TestStartUp(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
var lines []string
|
||||
|
||||
select {
|
||||
case lines = <-shown:
|
||||
case <-shown:
|
||||
case <-time.After(eventLoopTimeout):
|
||||
t.Fatalf("the status window did not get the welcome lines within %v",
|
||||
eventLoopTimeout)
|
||||
}
|
||||
|
||||
if !strings.Contains(lines[0], "Welcome to neoirc-cli") {
|
||||
t.Errorf("first status line is %q, want the welcome line", lines[0])
|
||||
}
|
||||
|
||||
if !strings.Contains(lines[1], "/connect <server-url>") {
|
||||
t.Errorf("second status line is %q, want the /connect hint", lines[1])
|
||||
}
|
||||
}
|
||||
|
||||
// TestOwnEventFromOtherClient checks that a message, notice,
|
||||
|
||||
Reference in new issue
Block a user