From 9b611f564f28d772829fa8529c1fae45925fe61a Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Tue, 1 Apr 2025 10:31:45 +0000 Subject: [PATCH 1/2] improve error handling in TestServer/EphemeralDeployment --- cli/server_test.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cli/server_test.go b/cli/server_test.go index f224fcb43fe63..92d1cb18a9ccf 100644 --- a/cli/server_test.go +++ b/cli/server_test.go @@ -201,7 +201,16 @@ func TestServer(t *testing.T) { go func() { errCh <- inv.WithContext(ctx).Run() }() - pty.ExpectMatch("Using an ephemeral deployment directory") + matchCh1 := make(chan string, 1) + go func() { + matchCh1 <- pty.ExpectMatchContext(ctx, "Using an ephemeral deployment directory") + }() + select { + case err := <-errCh: + require.NoError(t, err) + case <-matchCh1: + // OK! + } rootDirLine := pty.ReadLine(ctx) rootDir := strings.TrimPrefix(rootDirLine, "Using an ephemeral deployment directory") rootDir = strings.TrimSpace(rootDir) @@ -210,7 +219,16 @@ func TestServer(t *testing.T) { require.NotEmpty(t, rootDir) require.DirExists(t, rootDir) - pty.ExpectMatchContext(ctx, "View the Web UI") + matchCh2 := make(chan string, 1) + go func() { + matchCh2 <- pty.ExpectMatchContext(ctx, "View the Web UI") + }() + select { + case err := <-errCh: + require.NoError(t, err) + case <-matchCh2: + // OK! + } cancelFunc() <-errCh From 0aa2121a8df4eaf737949b33d30d7834bba9fa86 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Tue, 1 Apr 2025 11:00:31 +0000 Subject: [PATCH 2/2] comment --- cli/server_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/server_test.go b/cli/server_test.go index 92d1cb18a9ccf..715cbe5c7584c 100644 --- a/cli/server_test.go +++ b/cli/server_test.go @@ -221,6 +221,7 @@ func TestServer(t *testing.T) { matchCh2 := make(chan string, 1) go func() { + // The "View the Web UI" log is a decent indicator that the server was successfully started. matchCh2 <- pty.ExpectMatchContext(ctx, "View the Web UI") }() select { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy