...
1
16
17 package v1beta1
18
19 import (
20 "testing"
21
22 "github.com/google/go-cmp/cmp"
23 "k8s.io/api/flowcontrol/v1beta1"
24 "k8s.io/kubernetes/pkg/apis/flowcontrol"
25 )
26
27 func TestConvert_v1beta1_LimitedPriorityLevelConfiguration_To_flowcontrol_LimitedPriorityLevelConfiguration(t *testing.T) {
28 tests := []struct {
29 name string
30 in *v1beta1.LimitedPriorityLevelConfiguration
31 expected *flowcontrol.LimitedPriorityLevelConfiguration
32 }{
33 {
34 name: "nominal concurrency shares is set as expected",
35 in: &v1beta1.LimitedPriorityLevelConfiguration{
36 AssuredConcurrencyShares: 100,
37 LimitResponse: v1beta1.LimitResponse{
38 Type: v1beta1.LimitResponseTypeReject,
39 },
40 },
41 expected: &flowcontrol.LimitedPriorityLevelConfiguration{
42 NominalConcurrencyShares: 100,
43 LimitResponse: flowcontrol.LimitResponse{
44 Type: flowcontrol.LimitResponseTypeReject,
45 },
46 },
47 },
48 }
49
50 for _, test := range tests {
51 t.Run(test.name, func(t *testing.T) {
52 out := &flowcontrol.LimitedPriorityLevelConfiguration{}
53 if err := Convert_v1beta1_LimitedPriorityLevelConfiguration_To_flowcontrol_LimitedPriorityLevelConfiguration(test.in, out, nil); err != nil {
54 t.Errorf("Expected no error, but got: %v", err)
55 }
56 if !cmp.Equal(test.expected, out) {
57 t.Errorf("Expected a match, diff: %s", cmp.Diff(test.expected, out))
58 }
59 })
60 }
61 }
62
63 func TestConvert_flowcontrol_LimitedPriorityLevelConfiguration_To_v1beta1_LimitedPriorityLevelConfiguration(t *testing.T) {
64 tests := []struct {
65 name string
66 in *flowcontrol.LimitedPriorityLevelConfiguration
67 expected *v1beta1.LimitedPriorityLevelConfiguration
68 }{
69 {
70 name: "assured concurrency shares is set as expected",
71 in: &flowcontrol.LimitedPriorityLevelConfiguration{
72 NominalConcurrencyShares: 100,
73 LimitResponse: flowcontrol.LimitResponse{
74 Type: flowcontrol.LimitResponseTypeReject,
75 },
76 },
77 expected: &v1beta1.LimitedPriorityLevelConfiguration{
78 AssuredConcurrencyShares: 100,
79 LimitResponse: v1beta1.LimitResponse{
80 Type: v1beta1.LimitResponseTypeReject,
81 },
82 },
83 },
84 }
85
86 for _, test := range tests {
87 t.Run(test.name, func(t *testing.T) {
88 out := &v1beta1.LimitedPriorityLevelConfiguration{}
89 if err := Convert_flowcontrol_LimitedPriorityLevelConfiguration_To_v1beta1_LimitedPriorityLevelConfiguration(test.in, out, nil); err != nil {
90 t.Errorf("Expected no error, but got: %v", err)
91 }
92 if !cmp.Equal(test.expected, out) {
93 t.Errorf("Expected a match, diff: %s", cmp.Diff(test.expected, out))
94 }
95 })
96 }
97 }
98
View as plain text