-
Notifications
You must be signed in to change notification settings - Fork 1
/
logvelocityview_test.go
51 lines (48 loc) · 1.56 KB
/
logvelocityview_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 logview
import (
"github.com/gdamore/tcell/v2"
"testing"
"time"
)
func TestLogVelocityView_AutoScale(t *testing.T) {
screen := tcell.NewSimulationScreen("UTF-8")
screen.SetSize(10, 10)
velocity := NewLogVelocityView(time.Minute)
velocity.SetRect(0, 0, 10, 10)
velocity.Draw(screen)
start := time.Date(2021, 03, 01, 10, 0, 0, 0, time.Local)
end := start.Add(20 * time.Minute)
velocity.AutoScale(start, end)
if velocity.bucketWidth != 120 {
t.Errorf("Should have 2 minute bucket size, but got %d", velocity.bucketWidth)
}
end = start.Add(25 * time.Minute)
velocity.AutoScale(start, end)
if velocity.bucketWidth != 120 {
t.Errorf("Should have 2 minute bucket size, but got %d", velocity.bucketWidth)
}
end = start.Add(55 * time.Minute)
velocity.AutoScale(start, end)
if velocity.bucketWidth != 300 {
t.Errorf("Should have 5 minute bucket size, but got %d", velocity.bucketWidth)
}
}
func TestLogVelocityView_Scale(t *testing.T) {
screen := tcell.NewSimulationScreen("UTF-8")
screen.SetSize(10, 10)
velocity := NewLogVelocityView(time.Minute)
velocity.SetRect(0, 0, 10, 10)
velocity.Draw(screen)
velocity.ScaleFor(20 * time.Minute)
if velocity.bucketWidth != 120 {
t.Errorf("Should have 2 minute bucket size, but got %d", velocity.bucketWidth)
}
velocity.ScaleFor(25 * time.Minute)
if velocity.bucketWidth != 120 {
t.Errorf("Should have 2 minute bucket size, but got %d", velocity.bucketWidth)
}
velocity.ScaleFor(55 * time.Minute)
if velocity.bucketWidth != 300 {
t.Errorf("Should have 5 minute bucket size, but got %d", velocity.bucketWidth)
}
}