MCPcopy Index your code
hub / github.com/cli/cli / createTarGzBuffer

Function createTarGzBuffer

pkg/cmd/copilot/copilot_test.go:170–190  ·  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

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