packer-cn/common/iochan/iochan_test.go

29 lines
435 B
Go
Raw Normal View History

2019-04-11 08:18:49 -04:00
package iochan
import (
"bytes"
"reflect"
"strings"
"testing"
)
func TestLineReader(t *testing.T) {
data := []string{"foo", "bar", "baz"}
buf := new(bytes.Buffer)
buf.WriteString(strings.Join(data, "\n") + "\n")
ch := LineReader(buf)
var result []string
expected := data
for v := range ch {
result = append(result, v)
}
if !reflect.DeepEqual(result, expected) {
t.Fatalf("unexpected results: %#v", result)
}
}