X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/6b21fcf78372995c6d8130c63f2f8aa2609bf7fe..6c7859cfea123479aba046614ee81028651ddaf5:/terminal_client_helper_test.go?ds=sidebyside diff --git a/terminal_client_helper_test.go b/terminal_client_helper_test.go index 077d90c..5018e89 100644 --- a/terminal_client_helper_test.go +++ b/terminal_client_helper_test.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "io" "net" "strings" @@ -26,11 +27,6 @@ func (c *TerminalTestClient) Type(line string) { } } -// Output returns what the client showed. -func (c *TerminalTestClient) Output() string { - return c.out.String() -} - // WaitFor waits until the client showed text. func (c *TerminalTestClient) WaitFor(t *testing.T, text string) { t.Helper() @@ -40,11 +36,16 @@ func (c *TerminalTestClient) WaitFor(t *testing.T, text string) { }, 10*time.Second, time.Millisecond, "output so far: %q", c.Output()) } +// Output returns what the client showed. +func (c *TerminalTestClient) Output() string { + return c.out.String() +} + // Close ends the input and waits for the client. func (c *TerminalTestClient) Close() error { err := c.input.Close() if err != nil { - return err + return fmt.Errorf("close terminal input: %w", err) } return <-c.done @@ -69,7 +70,7 @@ func terminalStartTestClient(t *testing.T, socket string) *TerminalTestClient { }() t.Cleanup(func() { - _ = writer.Close() + require.NoError(t, writer.Close()) }) return client