forked from OpenReqEU/ri-orchestration-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobserver_test.go
More file actions
36 lines (29 loc) · 856 Bytes
/
Copy pathobserver_test.go
File metadata and controls
36 lines (29 loc) · 856 Bytes
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
package main
import (
"math"
"testing"
)
func TestUpdateAccount(t *testing.T) {
// Should not crash
updateAccount("WindItalia", "it")
}
func TestChunkTweets(t *testing.T) {
for _, tweetCount := range []int{0, 1, 15, 30, 50} {
tweets := make([]Tweet, 0, tweetCount)
for i := 0; i < tweetCount; i += 1 {
tweets = append(tweets, Tweet{})
}
chunks := chunkTweets(tweets)
expectedChunkCount := int(math.Ceil(float64(tweetCount) / 25.0))
if len(chunks) != expectedChunkCount {
t.Errorf("Wrong number of chunks.\nExpected %d but got %d.\n", expectedChunkCount, len(chunks))
}
chunkedTweetsCount := 0
for _, chunk := range chunks {
chunkedTweetsCount += len(chunk)
}
if chunkedTweetsCount != tweetCount {
t.Errorf("Wrong number of tweets in chunk.\nExpected %d but got %d.\n", tweetCount, chunkedTweetsCount)
}
}
}