Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95da8f8

Browse files
committed
fix other tests
1 parent 64cb41a commit 95da8f8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

provisioner/terraform/modules.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,18 @@ func getModules(workdir string) ([]*proto.Module, error) {
7272
}
7373

7474
func getModulesArchive(workdir string) ([]byte, error) {
75+
modulesDir := getModulesDirectory(workdir)
76+
if _, err := os.ReadDir(modulesDir); err != nil {
77+
if os.IsNotExist(err) {
78+
return []byte{}, nil
79+
}
80+
81+
return nil, err
82+
}
83+
7584
empty := true
7685
var b bytes.Buffer
7786
w := tar.NewWriter(&b)
78-
modulesDir := getModulesDirectory(workdir)
7987
err := filepath.WalkDir(modulesDir, func(filePath string, info fs.DirEntry, err error) error {
8088
if err != nil {
8189
return xerrors.Errorf("failed to create modules archive: %w", err)

provisioner/terraform/modules_internal_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import (
88
"strings"
99
"testing"
1010

11-
archivefs "github.com/coder/coder/v2/archive/fs"
1211
"github.com/stretchr/testify/require"
12+
13+
archivefs "github.com/coder/coder/v2/archive/fs"
1314
)
1415

1516
func TestGetModulesArchive(t *testing.T) {

0 commit comments

Comments
 (0)