blob: 6990f63c3e981308e47acc33e1c5f129f57a9c8b [file] [log] [blame]
Ricardo Zanini506962e2024-03-27 10:57:29 -03001// 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
15package cfg
16
17import (
18 "os"
19 "testing"
20
21 "github.com/stretchr/testify/assert"
22)
23
24func 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 Medvedeo5936bee2024-05-08 19:06:06 +020035 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 Medvedeo6db8d342024-05-13 18:25:24 +020040 Version: "3.8.4",
Walter Medvedeo5936bee2024-05-08 19:06:06 +020041 }, postgresExtensions[0])
42
43 assert.Equal(t, GAV{
44 GroupId: "io.quarkus",
45 ArtifactId: "quarkus-agroal",
Walter Medvedeo6db8d342024-05-13 18:25:24 +020046 Version: "3.8.4",
Walter Medvedeo5936bee2024-05-08 19:06:06 +020047 }, 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 Zanini506962e2024-03-27 10:57:29 -030054}
55
56func 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
65func 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}