kinesis-consumer/checkpoint_test.go
Harlow Ward f0e6461cb6 Refactor to use handler func
The previous pipeline model required a lot of setup and abstracted away
the processing of records. By passing a HandlerFunc to the consumer we
keep the business logic of processing of records closer to the use of
the consumer.

* Add refactoring note and SHA to README
2016-02-06 17:50:17 -08:00

46 lines
867 B
Go

package connector
import (
"testing"
"github.com/bmizerany/assert"
"github.com/hoisie/redis"
)
func Test_key(t *testing.T) {
c := Checkpoint{
AppName: "app",
StreamName: "stream",
}
k := c.key("shard")
assert.Equal(t, k, "app:checkpoint:stream:shard")
}
func Test_CheckpointExists(t *testing.T) {
var rc redis.Client
rc.Set("app:checkpoint:stream:shard", []byte("testSeqNum"))
c := Checkpoint{
AppName: "app",
StreamName: "stream",
}
r := c.CheckpointExists("shard")
assert.Equal(t, r, true)
rc.Del("app:checkpoint:stream:shard")
}
func Test_SetCheckpoint(t *testing.T) {
var rc redis.Client
c := Checkpoint{
AppName: "app",
StreamName: "stream",
}
c.SetCheckpoint("shard", "testSeqNum")
r, _ := rc.Get("app:checkpoint:stream:shard")
assert.Equal(t, string(r), "testSeqNum")
rc.Del("app:checkpoint:stream:shard")
}