Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
elena-kolevska authored Nov 13, 2024
2 parents b60d216 + e628128 commit 40912e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
12 changes: 5 additions & 7 deletions tests/integration/framework/tee/writecloser.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ func (w *writecloser) Write(p []byte) (n int, err error) {

for _, writer := range w.writers {
var n int
for {
written, err := writer.Write(p)
if err != nil {
for n < len(p) {
written, err := writer.Write(p[n:])
// If an error occurs and no bytes were written, add the error to the list of errors and break.
// If any bytes were written, continue writing until all bytes are written.
if err != nil && written == 0 {
errs = append(errs, err)
break
}

// Keep writing until all bytes are written to this writer.
n += written
if n == len(p) {
break
}
}
}

Expand Down
17 changes: 9 additions & 8 deletions tests/integration/framework/tee/writecloser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func TestWriteCloser(t *testing.T) {
default:
}

// Writes are sequential, so the write to pw2 should block until the first read is complete.
assert.Nil(t, pr2resp.Load())

resp = make([]byte, 1024)
Expand All @@ -149,15 +150,15 @@ func TestWriteCloser(t *testing.T) {
require.Fail(t, "timeout waiting for write to complete")
}

value := pr2resp.Load()
assert.NotNil(t, value)
require.EventuallyWithT(t, func(c *assert.CollectT) {
value := pr2resp.Load()
assert.NotNil(c, value)

strValue, ok := value.(string)
assert.True(t, ok)

if ok {
assert.Equal(t, "helloworld", strValue[:10])
}
strValue, ok := value.(string)
if assert.True(c, ok) {
assert.Equal(c, "helloworld", strValue[:10])
}
}, time.Second, 10*time.Millisecond)

require.NoError(t, w.Close())
n, err = pr1.Read(resp)
Expand Down

0 comments on commit 40912e3

Please sign in to comment.