-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
46 lines (41 loc) · 1.2 KB
/
main_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
package main
import "testing"
func TestReadArguments(t *testing.T) {
t.Run("verify with correct parameters", func(t *testing.T) {
want := int64(12)
args := []string{"12", "12"}
var load, percentage = readArguments(args)
if load != want || percentage != want {
t.Errorf("should have recieved a value back")
}
})
t.Run("verify with incorrect parameters", func(t *testing.T) {
args := []string{"not-a-number", "not-a-number"}
var load, percentage = readArguments(args)
if load != 0 && percentage != 0 {
t.Errorf("should have recieved zero")
}
})
}
func TestCaluatePercentage(t *testing.T) {
t.Run("calculates the percentage based on input", func(t *testing.T) {
percentageLoad := int64(78)
want := float64(0.78)
var percentage = calcuatePercentage(percentageLoad)
if want != percentage {
t.Errorf("should have recieved a value back")
}
})
}
func TestCalculateCPUCount(t *testing.T) {
t.Run("calculates the percentage based on input", func(t *testing.T) {
percentageLoad := float64(0.78)
CPU := 4
want := float64(3.12)
var percentage = calcuateCPUCount(percentageLoad, CPU)
print(percentage)
if want != percentage {
t.Errorf("should have recieved a value back")
}
})
}