100-go-mistakes/2-code-project-organization/5-interface-pollution/copy/main_test.go
2021-12-27 15:56:17 +01:00

23 lines
367 B
Go

package main
import (
"bytes"
"strings"
"testing"
)
func TestCopySourceToDest(t *testing.T) {
const input = "foo"
source := strings.NewReader(input)
dest := bytes.NewBuffer(make([]byte, 0))
err := copySourceToDest(source, dest)
if err != nil {
t.FailNow()
}
got := dest.String()
if got != input {
t.Errorf("expected: %s, got: %s", input, got)
}
}