forked from rewardStyle/kinetic
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshard_iterator_test.go
More file actions
58 lines (48 loc) · 1.86 KB
/
shard_iterator_test.go
File metadata and controls
58 lines (48 loc) · 1.86 KB
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
package kinetic
import (
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
. "github.com/smartystreets/goconvey/convey"
)
func TestShardIterator(t *testing.T) {
Convey("given a new shard iterator", t, func() {
it := NewShardIterator()
Convey("check that the default shard iterator type is TRIM_HORIZON", func() {
So(it.shardIteratorType, ShouldEqual, "TRIM_HORIZON")
So(it.getStartingSequenceNumber(), ShouldBeNil)
So(it.getTimestamp(), ShouldBeNil)
})
Convey("check that we can explicitly set it to TRIM_HORIZON", func() {
it = it.TrimHorizon()
So(it.shardIteratorType, ShouldEqual, "TRIM_HORIZON")
So(it.getStartingSequenceNumber(), ShouldBeNil)
So(it.getTimestamp(), ShouldBeNil)
})
Convey("check that we can explicitly set it to LATEST", func() {
it = it.Latest()
So(it.shardIteratorType, ShouldEqual, "LATEST")
So(it.getStartingSequenceNumber(), ShouldBeNil)
So(it.getTimestamp(), ShouldBeNil)
})
Convey("check that we can explicitly set it to AT_SEQEUENCE_NUMBER", func() {
it = it.AtSequenceNumber("some-sequence")
So(it.shardIteratorType, ShouldEqual, "AT_SEQUENCE_NUMBER")
So(aws.StringValue(it.getStartingSequenceNumber()), ShouldEqual, "some-sequence")
So(it.getTimestamp(), ShouldBeNil)
})
Convey("check that we can explicitly set it to AFTER_SEQEUENCE_NUMBER", func() {
it = it.AfterSequenceNumber("some-sequence")
So(it.shardIteratorType, ShouldEqual, "AFTER_SEQUENCE_NUMBER")
So(aws.StringValue(it.getStartingSequenceNumber()), ShouldEqual, "some-sequence")
So(it.getTimestamp(), ShouldBeNil)
})
Convey("check that we can explicitly set it to AT_TIMESTAMP", func() {
n := time.Now()
it = it.AtTimestamp(n)
So(it.shardIteratorType, ShouldEqual, "AT_TIMESTAMP")
So(aws.TimeValue(it.getTimestamp()).Equal(n), ShouldBeTrue)
So(it.getStartingSequenceNumber(), ShouldBeNil)
})
})
}