-
Notifications
You must be signed in to change notification settings - Fork 3
/
feedx_test.go
56 lines (44 loc) · 1.17 KB
/
feedx_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
package feedx_test
import (
"context"
"net/url"
"testing"
"time"
"github.com/bsm/bfs"
"github.com/bsm/feedx"
"github.com/bsm/feedx/internal/testdata"
. "github.com/bsm/ginkgo/v2"
. "github.com/bsm/gomega"
)
var memStore *bfs.InMem
func init() {
memStore = bfs.NewInMem()
bfs.Register("mem", func(_ context.Context, u *url.URL) (bfs.Bucket, error) {
return memStore, nil
})
}
// ------------------------------------------------------------------------
func seed() *testdata.MockMessage {
return &testdata.MockMessage{
Name: "Joe",
Enum: testdata.MockEnum_FIRST,
Height: 180,
}
}
var mockTime = time.Unix(1515151515, 123456789)
// ------------------------------------------------------------------------
func writeMulti(obj *bfs.Object, numEntries int, lastMod time.Time) error {
w := feedx.NewWriter(context.Background(), obj, &feedx.WriterOptions{LastMod: lastMod})
defer w.Discard()
for i := 0; i < numEntries; i++ {
if err := w.Encode(seed()); err != nil {
return err
}
}
return w.Commit()
}
// ------------------------------------------------------------------------
func TestSuite(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "feedx")
}