🎨 大部分的 make 指令
This commit is contained in:
47
pkg/archiver/archiver_test.go
Normal file
47
pkg/archiver/archiver_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package archiver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"gitea.loveuer.com/yizhisec/pkg3/logger"
|
||||
)
|
||||
|
||||
func TestDownloadAndExtract(t *testing.T) {
|
||||
logger.SetLogLevel(logger.LogLevelDebug)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Example: download and extract a tar.gz file
|
||||
err := DownloadAndExtract(
|
||||
ctx,
|
||||
"https://example.com/archive.tar.gz",
|
||||
"/tmp/test-extract",
|
||||
WithInsecureSkipVerify(),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
t.Logf("Expected error for test URL: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownloadAndExtractWithProgress(t *testing.T) {
|
||||
logger.SetLogLevel(logger.LogLevelDebug)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Example: with progress callback
|
||||
err := DownloadAndExtract(
|
||||
ctx,
|
||||
"https://example.com/archive.tar",
|
||||
"/tmp/test-extract",
|
||||
WithInsecureSkipVerify(),
|
||||
WithProgress(func(filename string, index int, total int) {
|
||||
t.Logf("Extracting: %s", filename)
|
||||
}),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
t.Logf("Expected error for test URL: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user