MCPcopy Create free account
hub / github.com/cli/cli / createTarGzBuffer

Function createTarGzBuffer

pkg/cmd/copilot/copilot_test.go:174–194  ·  view source on GitHub ↗

createTarGzBuffer creates a tar.gz archive in memory with the given files.

(t *testing.T, files map[string][]byte)

Source from the content-addressed store, hash-verified

172
173// createTarGzBuffer creates a tar.gz archive in memory with the given files.
174func createTarGzBuffer(t *testing.T, files map[string][]byte) []byte {
175 t.Helper()
176 var buf bytes.Buffer
177 gw := gzip.NewWriter(&buf)
178 tw := tar.NewWriter(gw)
179
180 for name, content := range files {
181 hdr := &tar.Header{
182 Name: name,
183 Mode: 0755,
184 Size: int64(len(content)),
185 }
186 require.NoError(t, tw.WriteHeader(hdr), "failed to write tar header")
187 _, err := tw.Write(content)
188 require.NoError(t, err, "failed to write tar content")
189 }
190
191 require.NoError(t, tw.Close(), "failed to close tar writer")
192 require.NoError(t, gw.Close(), "failed to close gzip writer")
193 return buf.Bytes()
194}
195
196// createZipBuffer creates a zip archive in memory with the given files.
197func createZipBuffer(t *testing.T, files map[string][]byte) []byte {

Callers 2

TestExtractTarGzFunction · 0.85
TestDownloadCopilotFunction · 0.85

Calls 3

HelperMethod · 0.65
WriteMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected