@@ -11,12 +11,15 @@ const fakeAccountNum = "123456789101"
11
11
12
12
func TestGetRancherLicense (t * testing.T ) {
13
13
tests := []struct {
14
- name string // name of the test, to be displayed on failure
15
- hasNonEmeaLicense bool // if the account has a license for the non-EMEA product sku
16
- hasEmeaLicense bool // if the account has a licensed for the EMEA product sku
17
- includeProductSku bool // if the return from aws should include or exclude a product sku
18
- desiredLicense string // which license our client should pick - emea, non-emea, or nothing
19
- errDesired bool // if we wanted an error for this test case
14
+ name string // name of the test, to be displayed on failure
15
+ hasNonEmeaLicense bool // if the account has a license for the non-EMEA product sku
16
+ hasEmeaLicense bool // if the account has a licensed for the EMEA product sku
17
+ hasTestNonEmeaLicense bool // if the account has a license for the test non-EMEA product sku
18
+ hasTestEmeaLicense bool // if the account has a license for the test EMEA product sku
19
+ usesTestIds bool // if the account is using a test product id
20
+ includeProductSku bool // if the return from aws should include or exclude a product sku
21
+ desiredLicense string // which license our client should pick - emea, non-emea, or nothing
22
+ errDesired bool // if we wanted an error for this test case
20
23
}{
21
24
{
22
25
name : "test non-emea license" ,
@@ -66,22 +69,67 @@ func TestGetRancherLicense(t *testing.T) {
66
69
desiredLicense : rancherProductSKUEmea ,
67
70
errDesired : false ,
68
71
},
72
+ {
73
+ name : "test non-emea test license" ,
74
+ hasTestNonEmeaLicense : true ,
75
+ usesTestIds : true ,
76
+ includeProductSku : true ,
77
+ desiredLicense : rancherProductTestSKUNonEmea ,
78
+ },
79
+ {
80
+ name : "test emea test license" ,
81
+ hasTestEmeaLicense : true ,
82
+ usesTestIds : true ,
83
+ includeProductSku : true ,
84
+ desiredLicense : rancherProductTestSKUEmea ,
85
+ },
86
+ {
87
+ name : "test non-emea + emea test license" ,
88
+ hasTestNonEmeaLicense : true ,
89
+ hasTestEmeaLicense : true ,
90
+ usesTestIds : true ,
91
+ includeProductSku : true ,
92
+ desiredLicense : rancherProductTestSKUNonEmea ,
93
+ },
94
+ {
95
+ name : "test non-emea test + prod skus, test requested, test used" ,
96
+ hasNonEmeaLicense : true ,
97
+ hasTestNonEmeaLicense : true ,
98
+ usesTestIds : true ,
99
+ includeProductSku : true ,
100
+ desiredLicense : rancherProductTestSKUNonEmea ,
101
+ },
102
+ {
103
+ name : "test non-emea test + prod skus, prod requested, prod used" ,
104
+ hasNonEmeaLicense : true ,
105
+ hasTestNonEmeaLicense : true ,
106
+ usesTestIds : false ,
107
+ includeProductSku : true ,
108
+ desiredLicense : rancherProductSKUNonEmea ,
109
+ },
69
110
}
70
111
for _ , test := range tests {
71
112
test := test
72
113
t .Run (test .name , func (t * testing.T ) {
73
114
mockLMClient := mockLicenseManagerClient {}
74
115
client := & client {
75
- acctNum : fakeAccountNum ,
76
- lm : & mockLMClient ,
77
- sts : & mockSTSClient {accountNumber : fakeAccountNum },
116
+ acctNum : fakeAccountNum ,
117
+ lm : & mockLMClient ,
118
+ sts : & mockSTSClient {accountNumber : fakeAccountNum },
119
+ useTestProducts : test .usesTestIds ,
78
120
}
79
121
if test .hasNonEmeaLicense {
80
122
mockLMClient .AddLicenseForSku (rancherProductSKUNonEmea , fakeAccountNum , test .includeProductSku )
81
123
}
124
+ if test .hasTestNonEmeaLicense {
125
+ mockLMClient .AddLicenseForSku (rancherProductTestSKUNonEmea , fakeAccountNum , test .includeProductSku )
126
+ }
82
127
if test .hasEmeaLicense {
83
128
mockLMClient .AddLicenseForSku (rancherProductSKUEmea , fakeAccountNum , test .includeProductSku )
84
129
}
130
+ if test .hasTestEmeaLicense {
131
+ mockLMClient .AddLicenseForSku (rancherProductTestSKUEmea , fakeAccountNum , test .includeProductSku )
132
+ }
85
133
86
134
license , err := client .GetRancherLicense (context .Background ())
87
135
if test .errDesired {
0 commit comments