createZipBuffer creates a zip archive in memory with the given files.
(t *testing.T, files map[string][]byte)
| 195 | |
| 196 | // createZipBuffer creates a zip archive in memory with the given files. |
| 197 | func createZipBuffer(t *testing.T, files map[string][]byte) []byte { |
| 198 | t.Helper() |
| 199 | var buf bytes.Buffer |
| 200 | zw := zip.NewWriter(&buf) |
| 201 | |
| 202 | for name, content := range files { |
| 203 | fw, err := zw.Create(name) |
| 204 | require.NoError(t, err, "failed to create zip entry") |
| 205 | _, err = fw.Write(content) |
| 206 | require.NoError(t, err, "failed to write zip content") |
| 207 | } |
| 208 | |
| 209 | require.NoError(t, zw.Close(), "failed to close zip writer") |
| 210 | return buf.Bytes() |
| 211 | } |
| 212 | |
| 213 | func TestExtractTarGz(t *testing.T) { |
| 214 | t.Run("extracts files correctly", func(t *testing.T) { |
no test coverage detected