20 lines
440 B
Go
20 lines
440 B
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
package ext
|
|
|
|
import (
|
|
"testing"
|
|
"github.com/stretchr/testify/assert"
|
|
"strings"
|
|
_ "fmt"
|
|
_ "log"
|
|
)
|
|
|
|
func TestNewWriteAddCloser(t *testing.T) {
|
|
var testWriter strings.Builder
|
|
|
|
closer := WriteAddCloser(WriteNopCloser(&testWriter), func() error { testWriter.Write([]byte("foo")); return nil })
|
|
closer.Close()
|
|
assert.Equal(t, "foo", testWriter.String())
|
|
}
|