2021-05-24 05:27:07 +00:00
|
|
|
package archive
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
2022-10-17 18:29:12 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2021-05-24 05:27:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestUnzipFile(t *testing.T) {
|
2022-09-14 05:59:47 +00:00
|
|
|
dir := t.TempDir()
|
2021-05-24 05:27:07 +00:00
|
|
|
/*
|
|
|
|
Archive structure.
|
|
|
|
├── 0
|
|
|
|
│ ├── 1
|
|
|
|
│ │ └── 2.txt
|
|
|
|
│ └── 1.txt
|
|
|
|
└── 0.txt
|
|
|
|
*/
|
|
|
|
|
2022-09-14 05:59:47 +00:00
|
|
|
err := UnzipFile("./testdata/sample_archive.zip", dir)
|
2021-05-24 05:27:07 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
archiveDir := dir + "/sample_archive"
|
|
|
|
assert.FileExists(t, filepath.Join(archiveDir, "0.txt"))
|
|
|
|
assert.FileExists(t, filepath.Join(archiveDir, "0", "1.txt"))
|
|
|
|
assert.FileExists(t, filepath.Join(archiveDir, "0", "1", "2.txt"))
|
|
|
|
|
|
|
|
}
|