|
1 | 1 | package terraform
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | +"archive/tar" |
4 | 5 | "bytes"
|
5 | 6 | "crypto/sha256"
|
6 | 7 | "encoding/hex"
|
| 8 | +"errors" |
| 9 | +"fmt" |
| 10 | +"io" |
7 | 11 | "io/fs"
|
8 | 12 | "os"
|
9 | 13 | "path/filepath"
|
@@ -54,13 +58,22 @@ func TestGetModulesArchive(t *testing.T) {
|
54 | 58 | _,err=fs.ReadFile(tarfs,".terraform/modules/stuff_that_should_not_be_included/nothing.txt")
|
55 | 59 | require.Error(t,err)
|
56 | 60 |
|
| 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 | + |
57 | 70 | // It should always be byte-identical to optimize storage
|
58 | 71 | hashBytes:=sha256.Sum256(archive)
|
59 | 72 | hash:=hex.EncodeToString(hashBytes[:])
|
60 | 73 | ifruntime.GOOS!="windows" {
|
61 |
| -require.Equal(t,"8491a8ab368f00a7eb0e927a957a3b0e4bf5df322c5b330d7b92b8b043a3d1d9",hash) |
| 74 | +require.Equal(t,"edcccdd4db68869552542e66bad87a51e2e455a358964912805a32b06123cb5c",hash) |
62 | 75 | }else {
|
63 |
| -require.Equal(t,"d15ae1791f19122a3ead806a225e1b79140432397b3543605505fe8b66e6ddf6",hash) |
| 76 | +require.Equal(t,"67027a27452d60ce2799fcfd70329c185f9aee7115b0944e3aa00b4776be9d92",hash) |
64 | 77 | }
|
65 | 78 | })
|
66 | 79 |
|
|