-
Notifications
You must be signed in to change notification settings - Fork 0
/
have_test.go
54 lines (48 loc) · 938 Bytes
/
have_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Streamy
// For the full copyright and license information, please view the LICENSE.txt file.
package streamy_test
import (
"bufio"
"bytes"
"io"
"os"
"testing"
"github.com/devfacet/streamy"
)
func TestHaveSeeker(t *testing.T) {
f, _ := os.Open("have_test.go")
table := []struct {
arg0 interface{}
want bool
}{
{bytes.Buffer{}, false},
{bufio.NewWriter(io.Discard), false},
{f, true},
}
for _, v := range table {
if b := streamy.HaveSeeker(v.arg0); b != v.want {
t.Errorf("got %v, want %v", b, v.want)
}
}
}
func TestHaveStdin(t *testing.T) {
table := []struct {
stdin bool
want bool
err error
}{
{false, false, nil},
}
for _, v := range table {
if v.stdin {
os.Stdin.WriteString("foo")
os.Stdin.Sync()
}
b, err := streamy.HaveStdin()
if b != v.want {
t.Errorf("got %v, want %v", b, v.want)
} else if err != v.err {
t.Errorf("got %v, want %v", err, v.err)
}
}
}