-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpod_test.go
61 lines (57 loc) · 1.19 KB
/
pod_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
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2023 Volvo Car Corporation
// SPDX-License-Identifier: Apache-2.0
package kubeutil
import (
"reflect"
"testing"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)
func TestResources(t *testing.T) {
type args struct {
cpuWant string
memWant string
cpuMax string
memMax string
}
tests := []struct {
name string
args args
want corev1.ResourceRequirements
}{
// TODO: Add test cases.
{
name: "ram cpu",
args: args{
cpuWant: "2",
memWant: "2Gi",
cpuMax: "4",
memMax: "4Gi",
},
want: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("2"),
corev1.ResourceMemory: resource.MustParse("2Gi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("4"),
corev1.ResourceMemory: resource.MustParse("4Gi"),
},
},
},
}
for _, tt := range tests {
t.Run(
tt.name, func(t *testing.T) {
if got := Resources(
tt.args.cpuWant,
tt.args.memWant,
tt.args.cpuMax,
tt.args.memMax,
); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Resources() = %v, want %v", got, tt.want)
}
},
)
}
}