-
Notifications
You must be signed in to change notification settings - Fork 1
/
kinsumer_integration_test.go
70 lines (62 loc) · 1.05 KB
/
kinsumer_integration_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//+build integration
package dynamodbkinsumer
import (
"log"
"sync"
"testing"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/satori/uuid"
"github.com/twitchscience/kinsumer"
)
func TestDynamoDBStreamsKinsumer(t *testing.T) {
sess, err := session.NewSession(&aws.Config{
Region: aws.String("us-east-2"),
})
if err != nil {
t.Errorf("%v", err)
return
}
k, err := NewWithSession(
sess,
"someTableName",
"PK",
"someAppName",
uuid.NewV4().String(),
kinsumer.NewConfig(),
)
if err != nil {
t.Errorf("%v", err)
return
}
err = k.CreateRequiredTables()
if err != nil {
t.Errorf("%v", err)
return
}
err = k.Run()
if err != nil {
t.Errorf("%v", err)
return
}
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
for {
record, err := k.Next()
if err != nil {
log.Fatalf("k.Next returned error %v", err)
}
if record != nil {
log.Printf("record: %+v\n", record)
} else {
return
}
}
}()
time.Sleep(5 * time.Minute)
k.Stop()
wg.Wait()
}