-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprobe_test.go
62 lines (40 loc) · 1.05 KB
/
probe_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
55
56
57
58
59
60
61
62
package cypress
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektra/neko"
)
func TestProbe(t *testing.T) {
n := neko.Start(t)
n.It("can detect if there is a header and read it", func() {
var buf ByteBuffer
enc := NewStreamEncoder(&buf)
enc.Init(SNAPPY)
probe := NewProbe(&buf)
err := probe.Probe()
require.NoError(t, err)
assert.Equal(t, SNAPPY, probe.Compression())
})
n.It("sets up a stream to use after the probe with a header", func() {
var buf ByteBuffer
enc := NewStreamEncoder(&buf)
enc.Init(SNAPPY)
probe := NewProbe(&buf)
err := probe.Probe()
require.NoError(t, err)
assert.Equal(t, SNAPPY, probe.Compression())
})
n.It("sets up a stream to use after the probe with no header", func() {
var buf ByteBuffer
buf.WriteString("{}\n")
probe := NewProbe(&buf)
err := probe.Probe()
require.NoError(t, err)
all, err := ioutil.ReadAll(probe.Stream)
require.NoError(t, err)
assert.Equal(t, "{}\n", string(all))
})
n.Meow()
}