|
| 1 | +package console_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/kyma-project/test-infra/development/tools/jobs/tester" |
| 7 | + "github.com/stretchr/testify/assert" |
| 8 | + "github.com/stretchr/testify/require" |
| 9 | +) |
| 10 | + |
| 11 | +func TestLogUIJobPresubmit(t *testing.T) { |
| 12 | + // WHEN |
| 13 | + jobConfig, err := tester.ReadJobConfig("./../../../../prow/jobs/console/log-ui/log-ui.yaml") |
| 14 | + // THEN |
| 15 | + require.NoError(t, err) |
| 16 | + |
| 17 | + assert.Len(t, jobConfig.Presubmits, 1) |
| 18 | + kymaPresubmits, ex := jobConfig.Presubmits["kyma-project/console"] |
| 19 | + assert.True(t, ex) |
| 20 | + assert.Len(t, kymaPresubmits, 1) |
| 21 | + |
| 22 | + expName := "pre-master-console-log-ui" |
| 23 | + actualPresubmit := tester.FindPresubmitJobByName(kymaPresubmits, expName, "master") |
| 24 | + require.NotNil(t, actualPresubmit) |
| 25 | + assert.Equal(t, expName, actualPresubmit.Name) |
| 26 | + assert.Equal(t, []string{"master"}, actualPresubmit.Branches) |
| 27 | + assert.Equal(t, 10, actualPresubmit.MaxConcurrency) |
| 28 | + assert.False(t, actualPresubmit.SkipReport) |
| 29 | + assert.True(t, actualPresubmit.Decorate) |
| 30 | + assert.False(t, actualPresubmit.Optional) |
| 31 | + assert.Equal(t, "github.com/kyma-project/console", actualPresubmit.PathAlias) |
| 32 | + tester.AssertThatHasExtraRefTestInfra(t, actualPresubmit.JobBase.UtilityConfig, "master") |
| 33 | + tester.AssertThatHasPresets(t, actualPresubmit.JobBase, tester.PresetDindEnabled, tester.PresetDockerPushRepo, tester.PresetGcrPush, tester.PresetBuildPr) |
| 34 | + assert.Equal(t, "^log-ui/", actualPresubmit.RunIfChanged) |
| 35 | + tester.AssertThatJobRunIfChanged(t, *actualPresubmit, "log-ui/some_random_file.js") |
| 36 | + assert.Equal(t, tester.ImageNodeBuildpackLatest, actualPresubmit.Spec.Containers[0].Image) |
| 37 | + assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/test-infra/prow/scripts/build.sh"}, actualPresubmit.Spec.Containers[0].Command) |
| 38 | + assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/console/log-ui"}, actualPresubmit.Spec.Containers[0].Args) |
| 39 | +} |
| 40 | + |
| 41 | +func TestLogUIJobPostsubmit(t *testing.T) { |
| 42 | + // WHEN |
| 43 | + jobConfig, err := tester.ReadJobConfig("./../../../../prow/jobs/console/log-ui/log-ui.yaml") |
| 44 | + // THEN |
| 45 | + require.NoError(t, err) |
| 46 | + |
| 47 | + assert.Len(t, jobConfig.Postsubmits, 1) |
| 48 | + kymaPost, ex := jobConfig.Postsubmits["kyma-project/console"] |
| 49 | + assert.True(t, ex) |
| 50 | + assert.Len(t, kymaPost, 1) |
| 51 | + |
| 52 | + expName := "post-master-console-log-ui" |
| 53 | + actualPost := tester.FindPostsubmitJobByName(kymaPost, expName, "master") |
| 54 | + require.NotNil(t, actualPost) |
| 55 | + assert.Equal(t, expName, actualPost.Name) |
| 56 | + assert.Equal(t, []string{"master"}, actualPost.Branches) |
| 57 | + |
| 58 | + assert.Equal(t, 10, actualPost.MaxConcurrency) |
| 59 | + assert.True(t, actualPost.Decorate) |
| 60 | + assert.Equal(t, "github.com/kyma-project/console", actualPost.PathAlias) |
| 61 | + tester.AssertThatHasExtraRefTestInfra(t, actualPost.JobBase.UtilityConfig, "master") |
| 62 | + tester.AssertThatHasPresets(t, actualPost.JobBase, tester.PresetDindEnabled, tester.PresetDockerPushRepo, tester.PresetGcrPush, tester.PresetBuildConsoleMaster) |
| 63 | + assert.Equal(t, "^log-ui/", actualPost.RunIfChanged) |
| 64 | + assert.Equal(t, tester.ImageNodeBuildpackLatest, actualPost.Spec.Containers[0].Image) |
| 65 | + assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/test-infra/prow/scripts/build.sh"}, actualPost.Spec.Containers[0].Command) |
| 66 | + assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/console/log-ui"}, actualPost.Spec.Containers[0].Args) |
| 67 | +} |
0 commit comments