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

Skip to content

Commit 5e39301

Browse files
committed
ok fine maybe fix it for real?? pls??
1 parent d7a9e6e commit 5e39301

File tree

1 file changed

+10
-35
lines changed

1 file changed

+10
-35
lines changed

provisioner/terraform/modules_internal_test.go

+10-35
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"crypto/sha256"
66
"encoding/hex"
7-
"fmt"
87
"io/fs"
98
"path/filepath"
109
"runtime"
@@ -18,9 +17,6 @@ import (
1817

1918
func TestGetModulesArchive(t *testing.T) {
2019
t.Parallel()
21-
if runtime.GOOS == "windows" {
22-
t.Skip()
23-
}
2420

2521
archive, err := getModulesArchive(filepath.Join("testdata", "modules-source-caching"))
2622
require.NoError(t, err)
@@ -31,39 +27,18 @@ func TestGetModulesArchive(t *testing.T) {
3127
content, err := fs.ReadFile(tarfs, ".terraform/modules/example_module/main.tf")
3228
require.NoError(t, err)
3329
require.True(t, strings.HasPrefix(string(content), "terraform {"))
34-
35-
require.Len(t, content, 3691)
36-
37-
// It should always be byte-identical to optimize storage
38-
hash := sha256.Sum256(archive)
39-
require.Equal(t, "05d2994c1a50ce573fe2c2b29507e5131ba004d15812d8bb0a46dc732f3211f5", hex.EncodeToString(hash[:]))
40-
}
41-
42-
// The .tar archive is different on Windows because of git converting LF line
43-
// endings to CRLF line endings.
44-
func TestGetModulesArchiveWindows(t *testing.T) {
45-
t.Parallel()
4630
if runtime.GOOS != "windows" {
47-
t.Skip()
31+
require.Len(t, content, 3691)
32+
} else {
33+
require.Len(t, content, 3812)
4834
}
4935

50-
archive, err := getModulesArchive(filepath.Join("testdata", "modules-source-caching"))
51-
require.NoError(t, err)
52-
53-
// debug time baby
54-
hashb := sha256.Sum256(archive)
55-
fmt.Println("archive hash:", hex.EncodeToString(hashb[:]))
56-
57-
// Check that all of the files it should contain are correct
58-
r := bytes.NewBuffer(archive)
59-
tarfs := archivefs.FromTarReader(r)
60-
content, err := fs.ReadFile(tarfs, ".terraform/modules/example_module/main.tf")
61-
fmt.Println("main.tf len:", len(content))
62-
require.NoError(t, err)
63-
require.True(t, strings.HasPrefix(string(content), "terraform {"))
64-
require.Len(t, content, 3691)
65-
6636
// It should always be byte-identical to optimize storage
67-
hash := sha256.Sum256(archive)
68-
require.Equal(t, "05d2994c1a50ce573fe2c2b29507e5131ba004d15812d8bb0a46dc732f3211f5", hex.EncodeToString(hash[:]))
37+
hashBytes := sha256.Sum256(archive)
38+
hash := hex.EncodeToString(hashBytes[:])
39+
if runtime.GOOS != "windows" {
40+
require.Equal(t, "05d2994c1a50ce573fe2c2b29507e5131ba004d15812d8bb0a46dc732f3211f5", hash)
41+
} else {
42+
require.Equal(t, "0001fc95ac0ac18188931db2ef28c42f51919ee24bc18482fab38d1ea9c7a4e8", hash)
43+
}
6944
}

0 commit comments

Comments
 (0)