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