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