Skip to content

Commit face432

Browse files
committed
Unit test improvements
1 parent 74dffd5 commit face432

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

pkg/deploy/controller/imagechange/controller_test.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ func TestHandle_changeForUnregisteredTag(t *testing.T) {
108108
}
109109
}
110110

111-
// TestHande_matchScenarios comprehensively tests trigger definitions against
111+
// TestHandle_matchScenarios comprehensively tests trigger definitions against
112112
// image repo updates to ensure that the image change triggers match (or don't
113113
// match) properly.
114-
func TestHande_matchScenarios(t *testing.T) {
114+
func TestHandle_matchScenarios(t *testing.T) {
115115
params := map[string]*deployapi.DeploymentTriggerImageChangeParams{
116116
"params.1": {
117117
Automatic: true,
@@ -133,13 +133,13 @@ func TestHande_matchScenarios(t *testing.T) {
133133
},
134134
}
135135

136-
tagHistoryFor := func(repo, tag, value string) map[string]imageapi.TagEventList {
136+
tagHistoryFor := func(repo, tag, dir, image string) map[string]imageapi.TagEventList {
137137
return map[string]imageapi.TagEventList{
138138
tag: {
139139
Items: []imageapi.TagEvent{
140140
{
141-
DockerImageReference: fmt.Sprintf("%s:%s", repo, value),
142-
Image: value,
141+
DockerImageReference: fmt.Sprintf("%s:%s", repo, dir),
142+
Image: image,
143143
},
144144
},
145145
},
@@ -151,30 +151,37 @@ func TestHande_matchScenarios(t *testing.T) {
151151
ObjectMeta: kapi.ObjectMeta{Name: "repoA", Namespace: kapi.NamespaceDefault},
152152
Status: imageapi.ImageRepositoryStatus{
153153
DockerImageRepository: "registry:8080/openshift/test-image",
154-
Tags: tagHistoryFor("registry:8080/openshift/test-image", "test-tag", "ref-2"),
154+
Tags: tagHistoryFor("registry:8080/openshift/test-image", "test-tag", "ref-2", "ref-2"),
155155
},
156156
Tags: map[string]string{"test-tag": "ref-2"},
157157
},
158158
"repo.2": {
159159
ObjectMeta: kapi.ObjectMeta{Name: "repoB", Namespace: kapi.NamespaceDefault},
160160
Status: imageapi.ImageRepositoryStatus{
161161
DockerImageRepository: "registry:8080/openshift/test-image",
162-
Tags: tagHistoryFor("registry:8080/openshift/test-image", "test-tag", "ref-3"),
162+
Tags: tagHistoryFor("registry:8080/openshift/test-image", "test-tag", "ref-3", "ref-3"),
163163
},
164164
Tags: map[string]string{"test-tag": "ref-3"},
165165
},
166166
"repo.3": {
167167
ObjectMeta: kapi.ObjectMeta{Name: "repoC", Namespace: kapi.NamespaceDefault},
168168
Status: imageapi.ImageRepositoryStatus{
169169
DockerImageRepository: "registry:8080/openshift/test-image-B",
170-
Tags: tagHistoryFor("registry:8080/openshift/test-image-B", "test-tag", "ref-2"),
170+
Tags: tagHistoryFor("registry:8080/openshift/test-image-B", "test-tag", "ref-2", "ref-2"),
171171
},
172172
Tags: map[string]string{"test-tag": "ref-2"},
173173
},
174174
"repo.4": {
175175
ObjectMeta: kapi.ObjectMeta{Name: "repoA", Namespace: kapi.NamespaceDefault},
176176
Status: imageapi.ImageRepositoryStatus{
177-
Tags: tagHistoryFor("default/repoA", "test-tag", "ref-2"),
177+
Tags: tagHistoryFor("default/repoA", "test-tag", "ref-2", "ref-2"),
178+
},
179+
Tags: map[string]string{"test-tag": "ref-2"},
180+
},
181+
"repo.5": {
182+
ObjectMeta: kapi.ObjectMeta{Name: "repoA", Namespace: kapi.NamespaceDefault},
183+
Status: imageapi.ImageRepositoryStatus{
184+
Tags: tagHistoryFor("default/repoA", "test-tag", "ref-2", ""),
178185
},
179186
Tags: map[string]string{"test-tag": "ref-2"},
180187
},

0 commit comments

Comments
 (0)