kinesis-consumer/store/memory/store_test.go

34 lines
717 B
Go
Raw Normal View History

package store
import (
2024-09-18 12:20:37 +00:00
"context"
2020-07-22 03:31:38 +00:00
"testing"
)
func Test_CheckpointLifecycle(t *testing.T) {
2020-07-22 03:31:38 +00:00
c := New()
2024-09-18 12:20:37 +00:00
ctx := context.Background()
2020-07-22 03:31:38 +00:00
// set
2024-09-18 12:20:37 +00:00
_ = c.SetCheckpoint(ctx, "streamName", "shardID", "testSeqNum")
2020-07-22 03:31:38 +00:00
// get
2024-09-18 12:20:37 +00:00
val, err := c.GetCheckpoint(ctx, "streamName", "shardID")
2020-07-22 03:31:38 +00:00
if err != nil {
t.Fatalf("get checkpoint error: %v", err)
}
if val != "testSeqNum" {
t.Fatalf("checkpoint exists expected %s, got %s", "testSeqNum", val)
}
}
func Test_SetEmptySeqNum(t *testing.T) {
2020-07-22 03:31:38 +00:00
c := New()
2024-09-18 12:20:37 +00:00
ctx := context.Background()
2024-09-18 12:20:37 +00:00
err := c.SetCheckpoint(ctx, "streamName", "shardID", "")
2020-07-22 03:31:38 +00:00
if err == nil || err.Error() != "sequence number should not be empty" {
t.Fatalf("should not allow empty sequence number")
}
}