@@ -33,21 +33,23 @@ const (
3333 validSecretName = "myregistry-credentials"
3434)
3535
36- func Test_needImageRegistryCredentialsConfiguration (t * testing.T ) {
36+ func Test_providerConfigsThatNeedConfiguration (t * testing.T ) {
3737 t .Parallel ()
3838
3939 testCases := []struct {
40- name string
41- configs []providerConfig
42- need bool
43- wantErr error
40+ name string
41+ configs []providerConfig
42+ expected [] providerConfig
43+ wantErr error
4444 }{
4545 {
4646 name : "ECR registry with no credentials" ,
4747 configs : []providerConfig {
4848 {URL : "https://123456789.dkr.ecr.us-east-1.amazonaws.com" },
4949 },
50- need : true ,
50+ expected : []providerConfig {
51+ {URL : "https://123456789.dkr.ecr.us-east-1.amazonaws.com" },
52+ },
5153 },
5254 {
5355 name : "registry with static credentials" ,
@@ -56,17 +58,22 @@ func Test_needImageRegistryCredentialsConfiguration(t *testing.T) {
5658 Username : "myuser" ,
5759 Password : "mypassword" ,
5860 }},
59- need : true ,
61+ expected : []providerConfig {{
62+ URL : "https://myregistry.com" ,
63+ Username : "myuser" ,
64+ Password : "mypassword" ,
65+ }},
6066 },
6167 {
6268 name : "ECR mirror with no credentials" ,
63- configs : []providerConfig {
64- {
65- URL : "https://123456789.dkr.ecr.us-east-1.amazonaws.com" ,
66- Mirror : true ,
67- },
68- },
69- need : true ,
69+ configs : []providerConfig {{
70+ URL : "https://123456789.dkr.ecr.us-east-1.amazonaws.com" ,
71+ Mirror : true ,
72+ }},
73+ expected : []providerConfig {{
74+ URL : "https://123456789.dkr.ecr.us-east-1.amazonaws.com" ,
75+ Mirror : true ,
76+ }},
7077 },
7178 {
7279 name : "mirror with static credentials" ,
@@ -76,15 +83,20 @@ func Test_needImageRegistryCredentialsConfiguration(t *testing.T) {
7683 Password : "mypassword" ,
7784 Mirror : true ,
7885 }},
79- need : true ,
86+ expected : []providerConfig {{
87+ URL : "https://mymirror.com" ,
88+ Username : "myuser" ,
89+ Password : "mypassword" ,
90+ Mirror : true ,
91+ }},
8092 },
8193 {
8294 name : "mirror with no credentials" ,
8395 configs : []providerConfig {{
8496 URL : "https://mymirror.com" ,
8597 Mirror : true ,
8698 }},
87- need : false ,
99+ expected : nil ,
88100 },
89101 {
90102 name : "a registry with static credentials and a mirror with no credentials" ,
@@ -100,7 +112,14 @@ func Test_needImageRegistryCredentialsConfiguration(t *testing.T) {
100112 Mirror : true ,
101113 },
102114 },
103- need : true ,
115+ expected : []providerConfig {
116+ {
117+ URL : "https://myregistry.com" ,
118+ Username : "myuser" ,
119+ Password : "mypassword" ,
120+ Mirror : false ,
121+ },
122+ },
104123 },
105124 {
106125 name : "a registry with missing credentials and a mirror with no credentials" ,
@@ -114,15 +133,13 @@ func Test_needImageRegistryCredentialsConfiguration(t *testing.T) {
114133 Mirror : true ,
115134 },
116135 },
117- need : false ,
118136 wantErr : ErrCredentialsNotFound ,
119137 },
120138 {
121139 name : "registry with missing credentials" ,
122140 configs : []providerConfig {{
123141 URL : "https://myregistry.com" ,
124142 }},
125- need : false ,
126143 wantErr : ErrCredentialsNotFound ,
127144 },
128145 {
@@ -131,7 +148,6 @@ func Test_needImageRegistryCredentialsConfiguration(t *testing.T) {
131148 URL : "https://myregistry.com" ,
132149 HasCACert : true ,
133150 }},
134- need : false ,
135151 },
136152 {
137153 name : "mirror with missing credentials but with a CA" ,
@@ -140,7 +156,6 @@ func Test_needImageRegistryCredentialsConfiguration(t *testing.T) {
140156 HasCACert : true ,
141157 Mirror : true ,
142158 }},
143- need : false ,
144159 },
145160 }
146161
@@ -150,9 +165,9 @@ func Test_needImageRegistryCredentialsConfiguration(t *testing.T) {
150165 t .Run (tt .name , func (t * testing.T ) {
151166 t .Parallel ()
152167
153- need , err := needImageRegistryCredentialsConfiguration (tt .configs )
168+ expected , err := providerConfigsThatNeedConfiguration (tt .configs )
154169 require .ErrorIs (t , err , tt .wantErr )
155- assert .Equal (t , tt .need , need )
170+ assert .Equal (t , tt .expected , expected )
156171 })
157172 }
158173}
0 commit comments