-
Notifications
You must be signed in to change notification settings - Fork 1
/
calculations_test.go
51 lines (43 loc) · 1.48 KB
/
calculations_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
package main
import (
"testing"
"time"
"github.com/brejoc/githubv4"
)
func TestCalculateCycleTime(t *testing.T) {
// loading test config
loadConfig("./test-data/test_config.toml")
currentTime := time.Now()
boardName := "test"
node1 := &node{}
node1.Typename = "MovedColumnsInProjectEvent"
node1.AddedEvent = addedEvent{}
node1.AddedEvent.Project = project{}
node1.AddedEvent.Project.Name = githubv4.String(boardName)
node1.AddedEvent.CreatedAt = githubv4.DateTime{currentTime.Add(time.Hour * -24)}
node1.MovedEvent = movedEvent{}
node1.MovedEvent.Project = project{}
node1.MovedEvent.Project.Name = githubv4.String(boardName)
node1.MovedEvent.PreviousProjectColumnName = "Planned"
node1.MovedEvent.ProjectColumnName = "Done"
node1.MovedEvent.CreatedAt = githubv4.DateTime{currentTime.Add(time.Hour * -24)}
timelineItems := queryTimelineItems{}
timelineItems.Nodes = []node{}
timelineItems.Nodes = append(timelineItems.Nodes, *node1)
want := time.Hour * 24
got := calculateCycleTime(timelineItems, node1.MovedEvent.CreatedAt,
githubv4.DateTime{currentTime}, boardName)
if got != want {
t.Errorf("Got %s for cycle time, but expected %s", got, want)
}
}
func TestCalculateLeadTime(t *testing.T) {
currentTime := time.Now()
want := (24 * time.Hour)
createdAt := githubv4.DateTime{currentTime}
closedAt := githubv4.DateTime{currentTime.Add(want)}
got := calculateLeadTime(createdAt, closedAt)
if got != want {
t.Errorf("Expected %s, but got %s for 'leadTime'", want, got)
}
}