open-vault/internalshared/gatedwriter/writer_test.go
Brian Kassouf 84dbca38a1
Revert "Migrate internalshared out (#9727)" (#10141)
This reverts commit ee6391b691ac12ab6ca13c3912404f1d3a842bd6.
2020-10-13 16:38:21 -07:00

35 lines
522 B
Go

package gatedwriter
import (
"bytes"
"io"
"testing"
)
func TestWriter_impl(t *testing.T) {
var _ io.Writer = new(Writer)
}
func TestWriter(t *testing.T) {
buf := new(bytes.Buffer)
w := NewWriter(buf)
w.Write([]byte("foo\n"))
w.Write([]byte("bar\n"))
if buf.String() != "" {
t.Fatalf("bad: %s", buf.String())
}
w.Flush()
if buf.String() != "foo\nbar\n" {
t.Fatalf("bad: %s", buf.String())
}
w.Write([]byte("baz\n"))
if buf.String() != "foo\nbar\nbaz\n" {
t.Fatalf("bad: %s", buf.String())
}
}