Skip to content

Commit 83d0403

Browse files
authored
use env vars for possible e2e test image substitution (#289)
Signed-off-by: Jordan Keister <[email protected]>
1 parent 61b563f commit 83d0403

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

test/e2e/e2e_suite_test.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package e2e
22

33
import (
44
"context"
5+
"os"
56
"testing"
67
"time"
78

@@ -30,10 +31,19 @@ var (
3031
)
3132

3233
const (
33-
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
34-
testCatalogName = "test-catalog"
34+
testCatalogRefEnvVar = "TEST_CATALOG_IMAGE"
35+
testCatalogRefDefault = "localhost/testdata/catalogs/test-catalog:e2e"
36+
testCatalogName = "test-catalog"
3537
)
3638

39+
// returns the image reference for the test, checking for environment variable substitution, with a default of localhost/testdata/catalogs/test-catalog:e2e
40+
func getCatalogImageRef() string {
41+
if s := os.Getenv(testCatalogRefEnvVar); s != "" {
42+
return s
43+
}
44+
return testCatalogRefDefault
45+
}
46+
3747
func TestE2E(t *testing.T) {
3848
RegisterFailHandler(Fail)
3949
SetDefaultEventuallyTimeout(1 * time.Minute)
@@ -55,7 +65,7 @@ var _ = BeforeSuite(func() {
5565
Expect(err).To(Not(HaveOccurred()))
5666

5767
ctx := context.Background()
58-
operatorCatalog, err = createTestCatalog(ctx, testCatalogName, testCatalogRef)
68+
operatorCatalog, err = createTestCatalog(ctx, testCatalogName, getCatalogImageRef())
5969
Expect(err).ToNot(HaveOccurred())
6070

6171
Eventually(func(g Gomega) {

test/e2e/install_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ var _ = Describe("Operator Install", func() {
147147

148148
By("creating an Operator catalog with the desired package")
149149
var err error
150-
operatorCatalog, err = createTestCatalog(ctx, testCatalogName, testCatalogRef)
150+
operatorCatalog, err = createTestCatalog(ctx, testCatalogName, getCatalogImageRef())
151151
Expect(err).ToNot(HaveOccurred())
152152
Eventually(func(g Gomega) {
153153
g.Expect(c.Get(ctx, types.NamespacedName{Name: operatorCatalog.Name}, operatorCatalog)).To(Succeed())

0 commit comments

Comments
 (0)