mirror of
https://github.com/FiloSottile/age.git
synced 2026-03-11 08:55:41 +00:00
internal/stream: fix TestRoundTrip
This commit is contained in:
parent
f90681e0df
commit
9821fcefc9
1 changed files with 18 additions and 1 deletions
|
|
@ -10,8 +10,10 @@ import (
|
|||
"bytes"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/FiloSottile/age/internal/format"
|
||||
"github.com/FiloSottile/age/internal/stream"
|
||||
"golang.org/x/crypto/chacha20poly1305"
|
||||
)
|
||||
|
|
@ -38,7 +40,19 @@ func testRoundTrip(t *testing.T, stepSize, length int) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
w, err := stream.NewWriter(key, buf)
|
||||
var closed bool
|
||||
bufCloser := struct {
|
||||
io.Writer
|
||||
format.CloserFunc
|
||||
}{
|
||||
Writer: buf,
|
||||
CloserFunc: func() error {
|
||||
closed = true
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
w, err := stream.NewWriter(key, bufCloser)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -70,6 +84,9 @@ func testRoundTrip(t *testing.T, stepSize, length int) {
|
|||
if err := w.Close(); err != nil {
|
||||
t.Error("Close returned an error:", err)
|
||||
}
|
||||
if !closed {
|
||||
t.Error("(*stream.Writer).Close didn't close the underlying WriteCloser")
|
||||
}
|
||||
|
||||
t.Logf("buffer size: %d", buf.Len())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue