-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5187 from openshift-cherrypick-robot/cherry-pick-…
…5133-to-release-4.15 [release-4.15] OCPBUGS-43931: Return the right tagReference on Catalogs ImageStream
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
control-plane-operator/controllers/hostedcontrolplane/olm/catalogs_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package olm | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestGetCatalogToImageWithISImageRegistryOverrides(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
catalogToImage map[string]string | ||
isImageRegistryOverrides map[string][]string | ||
expected map[string]string | ||
}{ | ||
{ | ||
name: "No overrides", | ||
catalogToImage: map[string]string{ | ||
"certified-operators": "registry.redhat.io/redhat/certified-operator-index:v4.16", | ||
"community-operators": "registry.redhat.io/redhat/community-operator-index:v4.16", | ||
}, | ||
isImageRegistryOverrides: map[string][]string{}, | ||
expected: map[string]string{ | ||
"certified-operators": "registry.redhat.io/redhat/certified-operator-index:v4.16", | ||
"community-operators": "registry.redhat.io/redhat/community-operator-index:v4.16", | ||
}, | ||
}, | ||
{ | ||
name: "Single override and different tag", | ||
catalogToImage: map[string]string{ | ||
"certified-operators": "registry.redhat.io/redhat/certified-operator-index:v4.17", | ||
"community-operators": "registry.redhat.io/redhat/community-operator-index:v4.17", | ||
}, | ||
isImageRegistryOverrides: map[string][]string{ | ||
"registry.redhat.io": {"custom.registry.io"}, | ||
}, | ||
expected: map[string]string{ | ||
"certified-operators": "custom.registry.io/redhat/certified-operator-index:v4.17", | ||
"community-operators": "custom.registry.io/redhat/community-operator-index:v4.17", | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
g := NewWithT(t) | ||
result := getCatalogToImageWithISImageRegistryOverrides(tt.catalogToImage, tt.isImageRegistryOverrides) | ||
g.Expect(result).To(Equal(tt.expected), "Expected %d entries, but got %d", len(tt.expected), len(result)) | ||
for key, expectedValue := range tt.expected { | ||
g.Expect(expectedValue).To(Equal(result[key]), "For key %s, expected %s, but got %s", key, expectedValue, result[key]) | ||
} | ||
}) | ||
} | ||
} |