gitee.com/h79/goutils@v1.22.10/common/archive/e7z/7z_test.go (about) 1 package e7z 2 3 import ( 4 "gitee.com/h79/goutils/common/file" 5 "gitee.com/h79/goutils/common/file/config" 6 "github.com/stretchr/testify/require" 7 "path/filepath" 8 "testing" 9 ) 10 11 func Test7Z(t *testing.T) { 12 tmp := t.TempDir() 13 filename := filepath.Join(tmp, "test.7z") 14 //f, err := os.Create() 15 //require.NoError(t, err) 16 //defer f.Close() // nolint: errcheck 17 archive := New(nil, tmp, filename) 18 defer archive.Close() // nolint: errcheck 19 20 require.NoError(t, archive.Add(config.File{ 21 Source: "../testdata/regular.txt", 22 Destination: "regular.txt", 23 })) 24 require.NoError(t, archive.Add(config.File{ 25 Source: "../testdata/sub1", 26 Destination: "sub1", 27 })) 28 29 file.CopyFile(filename, "test.7z") 30 }