|
1 | 1 | package terraform
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| -"archive/tar" |
5 | 4 | "bytes"
|
6 | 5 | "crypto/sha256"
|
7 | 6 | "encoding/hex"
|
8 |
| -"errors" |
9 |
| -"fmt" |
10 |
| -"io" |
11 | 7 | "io/fs"
|
12 | 8 | "os"
|
13 | 9 | "path/filepath"
|
@@ -58,22 +54,13 @@ func TestGetModulesArchive(t *testing.T) {
|
58 | 54 | _,err=fs.ReadFile(tarfs,".terraform/modules/stuff_that_should_not_be_included/nothing.txt")
|
59 | 55 | require.Error(t,err)
|
60 | 56 |
|
61 |
| -r:=tar.NewReader(bytes.NewBuffer(archive)) |
62 |
| -for { |
63 |
| -h,err:=r.Next() |
64 |
| -iferrors.Is(err,io.EOF) { |
65 |
| -break |
66 |
| -} |
67 |
| -fmt.Printf("- %v (%v) [%v:%v] %#v\n",h.Name,h.Size,h.Uid,h.Gid,h) |
68 |
| -} |
69 |
| - |
70 | 57 | // It should always be byte-identical to optimize storage
|
71 | 58 | hashBytes:=sha256.Sum256(archive)
|
72 | 59 | hash:=hex.EncodeToString(hashBytes[:])
|
73 | 60 | ifruntime.GOOS!="windows" {
|
74 | 61 | require.Equal(t,"8491a8ab368f00a7eb0e927a957a3b0e4bf5df322c5b330d7b92b8b043a3d1d9",hash)
|
75 | 62 | }else {
|
76 |
| -require.Equal(t,"c219943913051e4637527cd03ae2b7303f6945005a262cdd420f9c2af490d572",hash) |
| 63 | +require.Equal(t,"d15ae1791f19122a3ead806a225e1b79140432397b3543605505fe8b66e6ddf6",hash) |
77 | 64 | }
|
78 | 65 | })
|
79 | 66 |
|
|