(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestUploadReader(t *testing.T) { |
| 14 | // This is a smoke test in a single goroutine, without really testing the locking. |
| 15 | |
| 16 | data := bytes.Repeat([]byte{0x01}, 65535) |
| 17 | // No termination |
| 18 | ur := NewUploadReader(bytes.NewReader(data)) |
| 19 | read, err := io.ReadAll(ur) |
| 20 | require.NoError(t, err) |
| 21 | assert.Equal(t, data, read) |
| 22 | |
| 23 | // Terminated |
| 24 | ur = NewUploadReader(bytes.NewReader(data)) |
| 25 | readLen := len(data) / 2 |
| 26 | read, err = io.ReadAll(io.LimitReader(ur, int64(readLen))) |
| 27 | require.NoError(t, err) |
| 28 | assert.Equal(t, data[:readLen], read) |
| 29 | terminationErr := errors.New("Terminated") |
| 30 | ur.Terminate(terminationErr) |
| 31 | read, err = io.ReadAll(ur) |
| 32 | assert.Equal(t, terminationErr, err) |
| 33 | assert.Len(t, read, 0) |
| 34 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…