MCPcopy Create free account
hub / github.com/coder/coder / TestCreateTarFromZip_RejectsOversizedTarOverhead

Function TestCreateTarFromZip_RejectsOversizedTarOverhead

archive/archive_test.go:125–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func TestCreateTarFromZip_RejectsOversizedTarOverhead(t *testing.T) {
126 t.Parallel()
127
128 // Empty files keep the ZIP payload tiny while still forcing tar
129 // headers and end-of-archive blocks to consume output budget.
130 zipBytes := buildTestZip(t, map[string]string{
131 "empty-a.txt": "",
132 "empty-b.txt": "",
133 })
134
135 zr, err := zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
136 require.NoError(t, err)
137
138 // Two empty tar entries still need 2 header blocks plus the 2
139 // end-of-archive blocks, so the output is 2048 bytes and must
140 // exceed this limit.
141 tarBytes, err := archive.CreateTarFromZip(zr, 2047)
142 require.Error(t, err)
143 require.Nil(t, tarBytes)
144}
145
146func TestCreateZipFromTar(t *testing.T) {
147 t.Parallel()

Callers

nothing calls this directly

Calls 3

CreateTarFromZipFunction · 0.92
buildTestZipFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected