Skip to content

Commit

Permalink
use env vars for possible e2e test image substitution (operator-frame…
Browse files Browse the repository at this point in the history
…work#289)

Signed-off-by: Jordan Keister <jordan@nimblewidget.com>
  • Loading branch information
grokspawn committed Jul 6, 2023
1 parent 61b563f commit 83d0403
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package e2e

import (
"context"
"os"
"testing"
"time"

Expand Down Expand Up @@ -30,10 +31,19 @@ var (
)

const (
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
testCatalogName = "test-catalog"
testCatalogRefEnvVar = "TEST_CATALOG_IMAGE"
testCatalogRefDefault = "localhost/testdata/catalogs/test-catalog:e2e"
testCatalogName = "test-catalog"
)

// returns the image reference for the test, checking for environment variable substitution, with a default of localhost/testdata/catalogs/test-catalog:e2e
func getCatalogImageRef() string {
if s := os.Getenv(testCatalogRefEnvVar); s != "" {
return s
}
return testCatalogRefDefault
}

func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
SetDefaultEventuallyTimeout(1 * time.Minute)
Expand All @@ -55,7 +65,7 @@ var _ = BeforeSuite(func() {
Expect(err).To(Not(HaveOccurred()))

ctx := context.Background()
operatorCatalog, err = createTestCatalog(ctx, testCatalogName, testCatalogRef)
operatorCatalog, err = createTestCatalog(ctx, testCatalogName, getCatalogImageRef())
Expect(err).ToNot(HaveOccurred())

Eventually(func(g Gomega) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ var _ = Describe("Operator Install", func() {

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

0 comments on commit 83d0403

Please sign in to comment.