|
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,11 +58,20 @@ 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)\n",h.Name,h.Size) |
| 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,"b956016b8ddc50a0fe107f5f0e1d6a21e936df828e484be456969329dae0afee",hash) |
| 74 | +require.Equal(t,"b956016b8ddc50a0fe107f5f0e1d6a21e936df828e484be456969329dae0afe0",hash) |
62 | 75 | }else {
|
63 | 76 | require.Equal(t,"c219943913051e4637527cd03ae2b7303f6945005a262cdd420f9c2af490d572",hash)
|
64 | 77 | }
|
|