Skip to content

Commit 1057863

Browse files
committed
feat: adapt test
1 parent 40c13c3 commit 1057863

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

internal/flux_deployer/template_input.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import (
1010

1111
type TemplateInput map[string]any
1212

13-
func NewTemplateInput() TemplateInput {
14-
return make(TemplateInput)
15-
}
16-
1713
func NewTemplateInputFromConfig(c *config.BootstrapperConfig) TemplateInput {
1814
t := TemplateInput{
1915
"fluxCDEnvPath": "./" + EnvsDirectoryName + "/" + c.Environment + "/" + FluxCDDirectoryName,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package flux_deployer_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
8+
"github.com/openmcp-project/bootstrapper/internal/config"
9+
"github.com/openmcp-project/bootstrapper/internal/flux_deployer"
10+
)
11+
12+
func TestNewTemplateInputFromConfig(t *testing.T) {
13+
config := &config.BootstrapperConfig{
14+
Environment: "test-env",
15+
DeploymentRepository: config.DeploymentRepository{
16+
RepoURL: "test-repo-url",
17+
RepoBranch: "test-branch",
18+
},
19+
ImagePullSecrets: []string{"test-secret"},
20+
}
21+
22+
ti := flux_deployer.NewTemplateInputFromConfig(config)
23+
assert.NotNil(t, ti, "Expected non-nil TemplateInput")
24+
assert.Equal(t, "./envs/test-env/fluxcd", ti["fluxCDEnvPath"], "fluxCDEnvPath does not match")
25+
assert.Equal(t, "../../../resources/fluxcd", ti["fluxCDResourcesPath"], "fluxCDResourcesPath does not match")
26+
assert.Equal(t, "../../../resources/openmcp", ti["openMCPResourcesPath"], "openMCPResourcesPath does not match")
27+
assert.Equal(t, "test-branch", ti["gitRepoEnvBranch"], "gitRepoEnvBranch does not match")
28+
assert.Len(t, ti["imagePullSecrets"].([]map[string]string), 1, "imagePullSecrets length does not match")
29+
assert.Equal(t, "test-secret", ti["imagePullSecrets"].([]map[string]string)[0]["name"], "imagePullSecret name does not match")
30+
assert.Equal(t, "test-repo-url", ti["git"].(map[string]interface{})["repoUrl"], "git repoUrl does not match")
31+
assert.Equal(t, "test-branch", ti["git"].(map[string]interface{})["mainBranch"], "git mainBranch does not match")
32+
assert.Equal(t, "test-branch", ti["gitRepoEnvBranch"], "gitRepoEnvBranch does not match")
33+
}

0 commit comments

Comments
 (0)