Skip to content

Commit

Permalink
check override map in unit test for correct FileValues
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanHoladay committed Jun 4, 2024
1 parent 861f15f commit 85a5ad3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/pkg/bundle/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bundle
import (
"fmt"
"os"
"path/filepath"
"testing"

"github.com/defenseunicorns/uds-cli/src/types"
Expand Down Expand Up @@ -432,11 +433,12 @@ func TestHelmOverrideVariablePrecedence(t *testing.T) {
}

func TestFileVariableHandlers(t *testing.T) {
cwd, _ := os.Getwd()
const (
componentName = "test-component"
chartName = "test-chart"
pkgName = "test-package"
varName = "cert"
varName = "CERT"
path = "test.Cert"
relativePath = "../../../src/test/bundles/07-helm-overrides/variable-files/"
)
Expand All @@ -453,6 +455,7 @@ func TestFileVariableHandlers(t *testing.T) {
args args
loadEnv bool
requireNoErr bool
expected string
}{
{
name: "with --set",
Expand All @@ -479,6 +482,7 @@ func TestFileVariableHandlers(t *testing.T) {
chartName: chartName,
},
requireNoErr: true,
expected: fmt.Sprintf("%s=%s", path, filepath.Join(cwd, fmt.Sprintf("%s/test.cert", relativePath))),
},
{
name: "with UDS_VAR",
Expand All @@ -502,6 +506,7 @@ func TestFileVariableHandlers(t *testing.T) {
},
loadEnv: true,
requireNoErr: true,
expected: fmt.Sprintf("%s=%s", path, filepath.Join(cwd, fmt.Sprintf("%s/test.cert", relativePath))),
},
{
name: "with Config",
Expand Down Expand Up @@ -531,6 +536,7 @@ func TestFileVariableHandlers(t *testing.T) {
chartName: chartName,
},
requireNoErr: true,
expected: fmt.Sprintf("%s=%s", path, fmt.Sprintf("%stest.cert", relativePath)),
},
{
name: "with Bundle",
Expand All @@ -557,6 +563,7 @@ func TestFileVariableHandlers(t *testing.T) {
chartName: chartName,
},
requireNoErr: true,
expected: fmt.Sprintf("%s=%s", path, fmt.Sprintf("%stest.cert", relativePath)),
},
{
name: "file not found",
Expand All @@ -582,6 +589,7 @@ func TestFileVariableHandlers(t *testing.T) {
chartName: chartName,
},
requireNoErr: false,
expected: "",
},
}

Expand All @@ -597,6 +605,7 @@ func TestFileVariableHandlers(t *testing.T) {

if tc.requireNoErr {
require.NoError(t, err)
require.Contains(t, tc.expected, overrideMap[componentName][chartName].FileValues[0])
} else {
require.Contains(t, err.Error(), "unable to find")
}
Expand Down

0 comments on commit 85a5ad3

Please sign in to comment.