You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/api/archive/zip_test.go

29 lines
590 B

package archive
import (
"github.com/stretchr/testify/assert"
"path/filepath"
"testing"
)
func TestUnzipFile(t *testing.T) {
dir := t.TempDir()
/*
Archive structure.
0
1
2.txt
1.txt
0.txt
*/
err := UnzipFile("./testdata/sample_archive.zip", dir)
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"))
}