/
uploader_test.go
61 lines (55 loc) · 1.22 KB
/
uploader_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
package main
import (
"bytes"
"fmt"
"github.com/aws/aws-sdk-go/service/kinesis"
"testing"
"testing/quick"
)
func TestPack(t *testing.T) {
dest := []byte{'d', 'e', 'f'}
full := pack([]byte{'a', 'b', 'c'}, &dest)
if full {
t.Fatal("Should not be full")
}
expected := []byte{'d', 'e', 'f', '\n', 'a', 'b', 'c'}
for i, val := range expected {
if dest[i] != val {
t.Fatal("Bad packing: Expected %s but was actually %s", val, dest[i])
}
}
}
func TestPackEmptyDest(t *testing.T) {
dest := []byte{}
full := pack([]byte{'a', 'b', 'c'}, &dest)
if full {
t.Error("Buffer full when it shouldn't be")
}
if !bytes.Equal(dest, []byte{'a', 'b', 'c'}) {
t.Error("Bad packing of empty dest")
}
}
func TestPackQuick(t *testing.T) {
f := func(src, dest []byte) bool {
expected := make([]byte, len(dest))
copy(expected, dest)
full := pack(src, &dest)
if full {
return true
}
if len(expected) == 0 {
expected = src
} else {
expected = append(expected, '\n')
expected = append(expected, src...)
}
return bytes.Equal(dest, expected)
}
if err := quick.Check(f, nil); err != nil {
t.Error(err)
}
}
func TestRecords(t *testing.T) {
x := make([]*kinesis.PutRecordsRequestEntry, 10)
fmt.Printf("%s", x)
}