Skip to content
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
mtojek committed Jan 11, 2024
commit 2c9e7bac56903a1212d548fbb3796af097687449
40 changes: 40 additions & 0 deletions cli/templatevariables_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cli

import (
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
)

func TestParseVariableValuesFromVarsFiles(t *testing.T) {
// Given
tempDir, err := os.MkdirTemp(os.TempDir(), "test-parse-variable-values-from-vars-files-*")
require.NoError(t, err)

t.Cleanup(func() {
_ = os.RemoveAll(tempDir)
})

const (
hclFile1 = "file1.hcl"
jsonFile1 = "file1.json"
hclFile2 = "file2.hcl"
jsonFile2 = "file2.json"
)

err = os.WriteFile(hclFile1, []byte("s"), 0o600)

// When
actual, err := parseVariableValuesFromVarsFiles([]string{
filepath.Join(tempDir, hclFile1),
filepath.Join(tempDir, jsonFile1),
filepath.Join(tempDir, hclFile2),
filepath.Join(tempDir, jsonFile2),
})
require.NoError(t, err)

// Then

}
5 changes: 3 additions & 2 deletions cli/templatevariables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import (
"path/filepath"
"testing"

"github.com/coder/coder/v2/cli"
"github.com/stretchr/testify/require"

"github.com/coder/coder/v2/cli"
)

func TestDiscoverVarsFiles(t *testing.T) {
t.Parallel()

// Given
tempDir, err := os.MkdirTemp(os.TempDir(), "test-discover-vars-files")
tempDir, err := os.MkdirTemp(os.TempDir(), "test-discover-vars-files-*")
require.NoError(t, err)

t.Cleanup(func() {
Expand Down