|
| 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