Ricardo Zanini | 506962e | 2024-03-27 10:57:29 -0300 | [diff] [blame] | 1 | // Copyright 2024 Apache Software Foundation (ASF) |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package cfg |
| 16 | |
| 17 | import ( |
| 18 | "os" |
| 19 | "testing" |
| 20 | |
| 21 | "github.com/stretchr/testify/assert" |
| 22 | ) |
| 23 | |
| 24 | func TestInitializeControllersCfgAt_ValidFile(t *testing.T) { |
| 25 | cfg, err := InitializeControllersCfgAt("./testdata/controllers-cfg-test.yaml") |
| 26 | assert.NoError(t, err) |
| 27 | assert.NotNil(t, cfg) |
| 28 | |
| 29 | assert.Equal(t, int32(555), cfg.HealthFailureThresholdDevMode) |
| 30 | assert.Equal(t, "2Gi", cfg.DefaultPvcKanikoSize) |
| 31 | assert.Equal(t, "local/jobs-service:1.0.0", cfg.JobsServicePostgreSQLImageTag) |
| 32 | assert.Equal(t, "local/data-index:1.0.0", cfg.DataIndexPostgreSQLImageTag) |
| 33 | assert.Equal(t, "local/sonataflow-builder:1.0.0", cfg.SonataFlowBaseBuilderImageTag) |
| 34 | assert.Equal(t, "local/sonataflow-devmode:1.0.0", cfg.SonataFlowDevModeImageTag) |
Walter Medvedeo | 5936bee | 2024-05-08 19:06:06 +0200 | [diff] [blame] | 35 | assert.Equal(t, 3, len(cfg.PostgreSQLPersistenceExtensions)) |
| 36 | postgresExtensions := cfg.PostgreSQLPersistenceExtensions |
| 37 | assert.Equal(t, GAV{ |
| 38 | GroupId: "io.quarkus", |
| 39 | ArtifactId: "quarkus-jdbc-postgresql", |
Walter Medvedeo | 6db8d34 | 2024-05-13 18:25:24 +0200 | [diff] [blame^] | 40 | Version: "3.8.4", |
Walter Medvedeo | 5936bee | 2024-05-08 19:06:06 +0200 | [diff] [blame] | 41 | }, postgresExtensions[0]) |
| 42 | |
| 43 | assert.Equal(t, GAV{ |
| 44 | GroupId: "io.quarkus", |
| 45 | ArtifactId: "quarkus-agroal", |
Walter Medvedeo | 6db8d34 | 2024-05-13 18:25:24 +0200 | [diff] [blame^] | 46 | Version: "3.8.4", |
Walter Medvedeo | 5936bee | 2024-05-08 19:06:06 +0200 | [diff] [blame] | 47 | }, postgresExtensions[1]) |
| 48 | |
| 49 | assert.Equal(t, GAV{ |
| 50 | GroupId: "org.kie", |
| 51 | ArtifactId: "kie-addons-quarkus-persistence-jdbc", |
| 52 | Version: "999-SNAPSHOT", |
| 53 | }, postgresExtensions[2]) |
Ricardo Zanini | 506962e | 2024-03-27 10:57:29 -0300 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | func TestInitializeControllersCfgAt_FileNotFound(t *testing.T) { |
| 57 | cfg, err := InitializeControllersCfgAt("./whatever.yaml") |
| 58 | assert.Error(t, err) |
| 59 | assert.NotNil(t, cfg) //get the default |
| 60 | assert.True(t, os.IsNotExist(err)) |
| 61 | // defaults |
| 62 | assert.Equal(t, defaultControllersCfg, cfg) |
| 63 | } |
| 64 | |
| 65 | func TestInitializeControllersCfgAt_NotValidYaml(t *testing.T) { |
| 66 | cfg, err := InitializeControllersCfgAt("./testdata/controllers-cfg-invalid.yaml") |
| 67 | assert.NoError(t, err) |
| 68 | assert.NotNil(t, cfg) |
| 69 | // defaults |
| 70 | assert.Equal(t, defaultControllersCfg, cfg) |
| 71 | } |