test(client): remove obsolete query reader
- commit
- 2db8ed5d4800d01ae45080cf22ff88298ee04957
- author
- brice · · 2026-07-17 11:36 UTC
- parent
- 9bbe15f
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +0 -34
M internal/usecase/client/client_test.go +0 -34
| @@ -137,40 +137,6 @@ func (r *chunkedBlockingReader) Read(p []byte) (int, error) { | |||
| 137 | 137 | ||
| 138 | 138 | func (r *chunkedBlockingReader) unblock() { close(r.done) } | |
| 139 | 139 | ||
| 140 | - | // queryBoundaryReader reports an attempt to read the second chunk before | |
| 141 | - | // returning it, allowing a test to prove that a scheme re-query is a real | |
| 142 | - | // stdin generation boundary rather than a lossy notification. | |
| 143 | - | type queryBoundaryReader struct { | |
| 144 | - | first, second []byte | |
| 145 | - | secondRead chan struct{} | |
| 146 | - | allowSecond, done <-chan struct{} | |
| 147 | - | reads int | |
| 148 | - | } | |
| 149 | - | ||
| 150 | - | func (r *queryBoundaryReader) Read(p []byte) (int, error) { | |
| 151 | - | switch r.reads { | |
| 152 | - | case 0: | |
| 153 | - | r.reads++ | |
| 154 | - | return copy(p, r.first), nil | |
| 155 | - | case 1: | |
| 156 | - | select { | |
| 157 | - | case r.secondRead <- struct{}{}: | |
| 158 | - | case <-r.done: | |
| 159 | - | return 0, io.EOF | |
| 160 | - | } | |
| 161 | - | select { | |
| 162 | - | case <-r.allowSecond: | |
| 163 | - | r.reads++ | |
| 164 | - | return copy(p, r.second), nil | |
| 165 | - | case <-r.done: | |
| 166 | - | return 0, io.EOF | |
| 167 | - | } | |
| 168 | - | default: | |
| 169 | - | <-r.done | |
| 170 | - | return 0, io.EOF | |
| 171 | - | } | |
| 172 | - | } | |
| 173 | - | ||
| 174 | 140 | func newHappyTerminal(t *testing.T, out *bytes.Buffer, restoreCount *atomic.Int32, resizeCh chan domain.Size) (*portsmocks.MockTerminal, *blockingReader) { | |
| 175 | 141 | tm := portsmocks.NewMockTerminal(t) | |
| 176 | 142 | tm.EXPECT().Size().Return(domain.Size{Cols: 80, Rows: 24}, nil).Once() | |
| @@ -137,40 +137,6 @@ func (r *chunkedBlockingReader) Read(p []byte) (int, error) { | |||||
| 137 | 137 | ||||
| 138 | func (r *chunkedBlockingReader) unblock() { close(r.done) } | 138 | func (r *chunkedBlockingReader) unblock() { close(r.done) } | ||
| 139 | 139 | ||||
| 140 | - | // queryBoundaryReader reports an attempt to read the second chunk before | |||
| 141 | - | // returning it, allowing a test to prove that a scheme re-query is a real | |||
| 142 | - | // stdin generation boundary rather than a lossy notification. | |||
| 143 | - | type queryBoundaryReader struct { | |||
| 144 | - | first, second []byte | |||
| 145 | - | secondRead chan struct{} | |||
| 146 | - | allowSecond, done <-chan struct{} | |||
| 147 | - | reads int | |||
| 148 | - | } | |||
| 149 | - | ||||
| 150 | - | func (r *queryBoundaryReader) Read(p []byte) (int, error) { | |||
| 151 | - | switch r.reads { | |||
| 152 | - | case 0: | |||
| 153 | - | r.reads++ | |||
| 154 | - | return copy(p, r.first), nil | |||
| 155 | - | case 1: | |||
| 156 | - | select { | |||
| 157 | - | case r.secondRead <- struct{}{}: | |||
| 158 | - | case <-r.done: | |||
| 159 | - | return 0, io.EOF | |||
| 160 | - | } | |||
| 161 | - | select { | |||
| 162 | - | case <-r.allowSecond: | |||
| 163 | - | r.reads++ | |||
| 164 | - | return copy(p, r.second), nil | |||
| 165 | - | case <-r.done: | |||
| 166 | - | return 0, io.EOF | |||
| 167 | - | } | |||
| 168 | - | default: | |||
| 169 | - | <-r.done | |||
| 170 | - | return 0, io.EOF | |||
| 171 | - | } | |||
| 172 | - | } | |||
| 173 | - | ||||
| 174 | func newHappyTerminal(t *testing.T, out *bytes.Buffer, restoreCount *atomic.Int32, resizeCh chan domain.Size) (*portsmocks.MockTerminal, *blockingReader) { | 140 | func newHappyTerminal(t *testing.T, out *bytes.Buffer, restoreCount *atomic.Int32, resizeCh chan domain.Size) (*portsmocks.MockTerminal, *blockingReader) { | ||
| 175 | tm := portsmocks.NewMockTerminal(t) | 141 | tm := portsmocks.NewMockTerminal(t) | ||
| 176 | tm.EXPECT().Size().Return(domain.Size{Cols: 80, Rows: 24}, nil).Once() | 142 | tm.EXPECT().Size().Return(domain.Size{Cols: 80, Rows: 24}, nil).Once() | ||