Major changes: * Remove intermediate batching of kinesis records * Call the callback func with each record * Use functional options for config https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis Minor changes: * update README messaging about Kinesis -> Firehose functionality * remove unused buffer and emitter code
50 lines
1 KiB
Go
50 lines
1 KiB
Go
package redis
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gopkg.in/redis.v5"
|
|
)
|
|
|
|
var defaultAddr = "127.0.0.1:6379"
|
|
|
|
func Test_CheckpointLifecycle(t *testing.T) {
|
|
client := redis.NewClient(&redis.Options{Addr: defaultAddr})
|
|
|
|
c := &Checkpoint{
|
|
AppName: "app",
|
|
StreamName: "stream",
|
|
client: client,
|
|
}
|
|
|
|
// set checkpoint
|
|
c.SetCheckpoint("shard_id", "testSeqNum")
|
|
|
|
// checkpoint exists
|
|
if val := c.CheckpointExists("shard_id"); val != true {
|
|
t.Fatalf("checkpoint exists expected true, got %t", val)
|
|
}
|
|
|
|
// get checkpoint
|
|
if val := c.SequenceNumber(); val != "testSeqNum" {
|
|
t.Fatalf("checkpoint exists expected %s, got %s", "testSeqNum", val)
|
|
}
|
|
|
|
client.Del("app:checkpoint:stream:shard_id")
|
|
}
|
|
|
|
func Test_key(t *testing.T) {
|
|
client := redis.NewClient(&redis.Options{Addr: defaultAddr})
|
|
|
|
c := &Checkpoint{
|
|
AppName: "app",
|
|
StreamName: "stream",
|
|
client: client,
|
|
}
|
|
|
|
expected := "app:checkpoint:stream:shard"
|
|
|
|
if val := c.key("shard"); val != expected {
|
|
t.Fatalf("checkpoint exists expected %s, got %s", expected, val)
|
|
}
|
|
}
|