chore: update testutil chan helpers (#17408)

This commit is contained in:
ケイラ
2025-04-16 10:37:09 -06:00
committed by GitHub
parent 2a76f5028e
commit f670bc31f5
45 changed files with 582 additions and 559 deletions
+7 -7
View File
@@ -35,7 +35,7 @@ func TestPrompt(t *testing.T) {
}()
ptty.ExpectMatch("Example")
ptty.WriteLine("hello")
resp := testutil.RequireRecvCtx(ctx, t, msgChan)
resp := testutil.TryReceive(ctx, t, msgChan)
require.Equal(t, "hello", resp)
})
@@ -54,7 +54,7 @@ func TestPrompt(t *testing.T) {
}()
ptty.ExpectMatch("Example")
ptty.WriteLine("yes")
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
resp := testutil.TryReceive(ctx, t, doneChan)
require.Equal(t, "yes", resp)
})
@@ -91,7 +91,7 @@ func TestPrompt(t *testing.T) {
doneChan <- resp
}()
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
resp := testutil.TryReceive(ctx, t, doneChan)
require.Equal(t, "yes", resp)
// Close the reader to end the io.Copy
require.NoError(t, ptty.Close(), "close eof reader")
@@ -115,7 +115,7 @@ func TestPrompt(t *testing.T) {
}()
ptty.ExpectMatch("Example")
ptty.WriteLine("{}")
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
resp := testutil.TryReceive(ctx, t, doneChan)
require.Equal(t, "{}", resp)
})
@@ -133,7 +133,7 @@ func TestPrompt(t *testing.T) {
}()
ptty.ExpectMatch("Example")
ptty.WriteLine("{a")
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
resp := testutil.TryReceive(ctx, t, doneChan)
require.Equal(t, "{a", resp)
})
@@ -153,7 +153,7 @@ func TestPrompt(t *testing.T) {
ptty.WriteLine(`{
"test": "wow"
}`)
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
resp := testutil.TryReceive(ctx, t, doneChan)
require.Equal(t, `{"test":"wow"}`, resp)
})
@@ -178,7 +178,7 @@ func TestPrompt(t *testing.T) {
}()
ptty.ExpectMatch("Example")
ptty.WriteLine("foo\nbar\nbaz\n\n\nvalid\n")
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
resp := testutil.TryReceive(ctx, t, doneChan)
require.Equal(t, "valid", resp)
})
}