MCPcopy Create free account
hub / github.com/Unpackerr/unpackerr / makeNestedZipFixture

Function makeNestedZipFixture

pkg/unpackerr/folder_recursion_test.go:124–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

122}
123
124func makeNestedZipFixture(t *testing.T) string {
125 t.Helper()
126
127 tmpDir := t.TempDir()
128 archivePath := filepath.Join(tmpDir, "test.zip")
129
130 innerZipBytes, err := buildZip(map[string][]byte{
131 "nested-only.txt": []byte("inner payload"),
132 })
133 if err != nil {
134 t.Fatalf("building inner zip fixture: %v", err)
135 }
136
137 outerZipBytes, err := buildZip(map[string][]byte{
138 "folder1/inner.zip": innerZipBytes,
139 "folder2/root.txt": []byte("outer payload"),
140 })
141 if err != nil {
142 t.Fatalf("building outer zip fixture: %v", err)
143 }
144
145 if err := os.WriteFile(archivePath, outerZipBytes, 0o600); err != nil {
146 t.Fatalf("writing outer zip fixture: %v", err)
147 }
148
149 return archivePath
150}
151
152func buildZip(entries map[string][]byte) ([]byte, error) {
153 var output bytes.Buffer

Calls 1

buildZipFunction · 0.85

Tested by

no test coverage detected