Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
837275fa92 |
@@ -4,8 +4,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"slices"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -361,8 +359,7 @@ 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 two lines: first the one that holds "Welcome to
|
// window gets the welcome lines.
|
||||||
// neoirc-cli", then the /connect hint.
|
|
||||||
func TestStartUp(t *testing.T) {
|
func TestStartUp(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -389,22 +386,16 @@ 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 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
|
// the event loop, so the reads run on a goroutine too, which
|
||||||
// this test stops waiting for after eventLoopTimeout. The
|
// this test stops waiting for after eventLoopTimeout.
|
||||||
// channel has one slot, so that goroutine can still end.
|
shown := make(chan struct{})
|
||||||
shown := make(chan []string, 1)
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
var lines []string
|
lines, _ := bufferState(ui, "(status)")
|
||||||
|
if lines == welcomeLines {
|
||||||
ui.app.QueueUpdate(func() {
|
close(shown)
|
||||||
lines = slices.Clone(ui.getOrCreateBuffer("(status)").Lines)
|
|
||||||
})
|
|
||||||
|
|
||||||
if len(lines) == welcomeLines {
|
|
||||||
shown <- lines
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -413,22 +404,12 @@ func TestStartUp(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var lines []string
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case lines = <-shown:
|
case <-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