Skip to content

Commit

Permalink
test(secrets): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
metal3d committed Nov 25, 2024
1 parent 36984e3 commit dc34d32
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions generator/secret_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package generator

import (
"bytes"
"fmt"
"katenary/generator/labels"
"os"
Expand Down Expand Up @@ -44,3 +45,49 @@ services:
t.Errorf("Expected BAR to be baz, got %s", data["BAR"])
}
}

func TestCreateSecretFromEnvironmentWithValue(t *testing.T) {
composeFile := `
services:
web:
image: nginx:1.29
environment:
- FOO=bar
- BAR=baz
labels:
%[1]s/secrets: |-
- BAR
%[1]s/values: |-
- BAR
`
composeFile = fmt.Sprintf(composeFile, labels.KatenaryLabelPrefix)
tmpDir := setup(composeFile)
defer teardown(tmpDir)

currentDir, _ := os.Getwd()
os.Chdir(tmpDir)
defer os.Chdir(currentDir)

force := false
outputDir := "./chart"
profiles := make([]string, 0)
helmdepUpdate := true
var appVersion *string
chartVersion := "0.1.0"
convertOptions := ConvertOptions{
Force: force,
OutputDir: outputDir,
Profiles: profiles,
HelmUpdate: helmdepUpdate,
AppVersion: appVersion,
ChartVersion: chartVersion,
}
Convert(convertOptions, "compose.yml")
c, err := os.ReadFile("chart/values.yaml")
if err != nil {
t.Fatal(err)
}
if !bytes.Contains(c, []byte("BAR: baz")) {
t.Errorf("Expected BAR to be baz, got %s", c)
}
}

0 comments on commit dc34d32

Please sign in to comment.