|
| 1 | +package tests |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + helmtests "github.com/airbytehq/airbyte-platform-internal/oss/charts/helm-tests" |
| 7 | + "github.com/stretchr/testify/assert" |
| 8 | +) |
| 9 | + |
| 10 | +func TestDefaultConnectorImageRegistry(t *testing.T) { |
| 11 | + opts := helmtests.BaseHelmOptions() |
| 12 | + chartYaml, err := helmtests.RenderHelmChart(t, opts, chartPath, "airbyte", nil) |
| 13 | + assert.NoError(t, err) |
| 14 | + |
| 15 | + expectedEnvVars := []helmtests.ExpectedEnvVar{ |
| 16 | + helmtests.ExpectedConfigMapVar().RefName("airbyte-airbyte-env").RefKey("JOB_KUBE_CONNECTOR_IMAGE_REGISTRY").Value(""), |
| 17 | + } |
| 18 | + |
| 19 | + releaseApps := appsForRelease("airbyte") |
| 20 | + rapp := releaseApps["workload-launcher"] |
| 21 | + app := chartYaml.GetResourceByKindAndName(rapp.Kind, rapp.FQN()) |
| 22 | + assert.NotNil(t, app, "unable to find %s named '%s'", rapp.Kind, rapp.FQN()) |
| 23 | + |
| 24 | + pod := helmtests.GetPodSpec(app) |
| 25 | + assert.NotNil(t, pod, "unable to extract pod spec from %s: %s", rapp.Kind, rapp.FQN()) |
| 26 | + chartYaml.VerifyEnvVarsForApp(t, rapp.Kind, rapp.FQN(), expectedEnvVars) |
| 27 | +} |
| 28 | + |
| 29 | +func TestOverrideConnectorImageRegistry(t *testing.T) { |
| 30 | + opts := helmtests.BaseHelmOptions() |
| 31 | + opts.SetValues["global.image.registry"] = "not-the-default" |
| 32 | + chartYaml, err := helmtests.RenderHelmChart(t, opts, chartPath, "airbyte", nil) |
| 33 | + assert.NoError(t, err) |
| 34 | + |
| 35 | + expectedEnvVars := []helmtests.ExpectedEnvVar{ |
| 36 | + helmtests.ExpectedConfigMapVar().RefName("airbyte-airbyte-env").RefKey("JOB_KUBE_CONNECTOR_IMAGE_REGISTRY").Value("not-the-default"), |
| 37 | + } |
| 38 | + |
| 39 | + releaseApps := appsForRelease("airbyte") |
| 40 | + rapp := releaseApps["workload-launcher"] |
| 41 | + app := chartYaml.GetResourceByKindAndName(rapp.Kind, rapp.FQN()) |
| 42 | + assert.NotNil(t, app, "unable to find %s named '%s'", rapp.Kind, rapp.FQN()) |
| 43 | + |
| 44 | + pod := helmtests.GetPodSpec(app) |
| 45 | + assert.NotNil(t, pod, "unable to extract pod spec from %s: %s", rapp.Kind, rapp.FQN()) |
| 46 | + chartYaml.VerifyEnvVarsForApp(t, rapp.Kind, rapp.FQN(), expectedEnvVars) |
| 47 | +} |
0 commit comments