-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
51 lines (45 loc) · 975 Bytes
/
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
47
48
49
50
51
package main
import (
"errors"
"reflect"
"testing"
)
var normalizeInstanceScenarios = []struct {
input map[string]int64
expected map[string]float32
expectedErr error
}{
{
map[string]int64{
"c5.xlarge": 40,
"c5.2xlarge": 50,
"m4.4xlarge": 10,
"m4.large": 100,
},
map[string]float32{
"c5": 280,
"m4": 180,
},
nil,
},
{
map[string]int64{
"c5": 10,
"large": 20,
},
map[string]float32{},
errors.New(BadInstancesInput),
},
}
// test correct calculations
func TestNormalizeInstances(t *testing.T) {
for _, scenario := range normalizeInstanceScenarios {
res, err := normalizeInstances(scenario.input)
if !reflect.DeepEqual(res, scenario.expected) {
t.Errorf("Expected normalizeInstances to be:\n`%v`\nGot:\n`%v`", scenario.expected, res)
}
if !reflect.DeepEqual(err, scenario.expectedErr) {
t.Errorf("Did not get expected error. Expected:\n`%v`\nGot:\n`%v`", scenario.expectedErr, err)
}
}
}