Skip to content

Commit

Permalink
test: add unit test for UnwrapNopCloser
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Zhang <[email protected]>
  • Loading branch information
shizhMSFT committed Mar 19, 2024
1 parent 4fc2a3b commit 7099a5a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions internal/ioutil/io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import (
)

func TestUnwrapNopCloser(t *testing.T) {
var reader struct {
io.Reader
}
var readerWithWriterTo struct {
io.Reader
io.WriterTo
}

tests := []struct {
name string
rc io.Reader
Expand All @@ -37,9 +45,14 @@ func TestUnwrapNopCloser(t *testing.T) {
name: "nil",
},
{
name: "no-op closer",
rc: io.NopCloser(os.Stdin),
want: os.Stdin,
name: "no-op closer with plain io.Reader",
rc: io.NopCloser(reader),
want: reader,
},
{
name: "no-op closer with io.WriteTo",
rc: io.NopCloser(readerWithWriterTo),
want: readerWithWriterTo,
},
{
name: "any ReadCloser",
Expand Down

0 comments on commit 7099a5a

Please sign in to comment.