-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjob_test.go
More file actions
36 lines (32 loc) · 720 Bytes
/
job_test.go
File metadata and controls
36 lines (32 loc) · 720 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 piper
import (
"fmt"
"math/rand"
"testing"
)
func TestJob_NewJob(t *testing.T) {
j := newJob(newTestData(1))
if j == nil {
t.Fatal("newJob returned nil")
}
}
func TestJob_IncrementRetry(t *testing.T) {
j := newJob(newTestData(2))
count := rand.Intn(10) + 1
for i := 0; i < count; i++ {
j.incrementRetry()
}
if j.retries != count {
t.Fatalf("invalid retry count: wanted [%d], got [%d]", count, j.retries)
}
}
func TestJob_AddError(t *testing.T) {
j := newJob(newTestData(3))
count := rand.Intn(10) + 1
for i := 0; i < count; i++ {
j.addError(fmt.Errorf("Error#%d", i))
}
if len(j.errors) != count {
t.Fatalf("invalid errors count: wanted [%d], got [%d]", count, len(j.errors))
}
}