Skip to content

Commit 2c9e7ba

Browse files
committed
WIP
1 parent ec65ea3 commit 2c9e7ba

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package cli
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
"testing"
7+
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestParseVariableValuesFromVarsFiles(t *testing.T) {
12+
// Given
13+
tempDir, err := os.MkdirTemp(os.TempDir(), "test-parse-variable-values-from-vars-files-*")
14+
require.NoError(t, err)
15+
16+
t.Cleanup(func() {
17+
_ = os.RemoveAll(tempDir)
18+
})
19+
20+
const (
21+
hclFile1 = "file1.hcl"
22+
jsonFile1 = "file1.json"
23+
hclFile2 = "file2.hcl"
24+
jsonFile2 = "file2.json"
25+
)
26+
27+
err = os.WriteFile(hclFile1, []byte("s"), 0o600)
28+
29+
// When
30+
actual, err := parseVariableValuesFromVarsFiles([]string{
31+
filepath.Join(tempDir, hclFile1),
32+
filepath.Join(tempDir, jsonFile1),
33+
filepath.Join(tempDir, hclFile2),
34+
filepath.Join(tempDir, jsonFile2),
35+
})
36+
require.NoError(t, err)
37+
38+
// Then
39+
40+
}

cli/templatevariables_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import (
55
"path/filepath"
66
"testing"
77

8-
"github.com/coder/coder/v2/cli"
98
"github.com/stretchr/testify/require"
9+
10+
"github.com/coder/coder/v2/cli"
1011
)
1112

1213
func TestDiscoverVarsFiles(t *testing.T) {
1314
t.Parallel()
1415

1516
// Given
16-
tempDir, err := os.MkdirTemp(os.TempDir(), "test-discover-vars-files")
17+
tempDir, err := os.MkdirTemp(os.TempDir(), "test-discover-vars-files-*")
1718
require.NoError(t, err)
1819

1920
t.Cleanup(func() {

0 commit comments

Comments
 (0)