test: cover archive file selection helpers

This commit is contained in:
2026-09-12 16:47:39 +03:00
parent c9a9eaf1dc
commit 176ee61606
+20
View File
@@ -28,6 +28,26 @@ func TestExtractArchiveFromReaderTXT(t *testing.T) {
} }
} }
func TestArchiveFileSelectionHelpers(t *testing.T) {
extensions := SupportedArchiveExtensions()
if len(extensions) == 0 || extensions[0] != ".ahs" {
t.Fatalf("unexpected supported extensions: %v", extensions)
}
if !IsSupportedArchiveFilename("report.TGZ") || IsSupportedArchiveFilename("report.bin") {
t.Fatal("unexpected supported archive detection")
}
files := []ExtractedFile{{Path: "logs/System.LOG"}, {Path: "config.json"}, {Path: "nested/event.log"}}
if got := FindFileByPattern(files, "log"); len(got) != 2 {
t.Fatalf("FindFileByPattern = %+v", got)
}
if got := FindFileByName(files, "EVENT.LOG"); got == nil || got.Path != "nested/event.log" {
t.Fatalf("FindFileByName = %+v", got)
}
if got := FindFileByName(files, "missing"); got != nil {
t.Fatalf("expected missing file, got %+v", got)
}
}
func TestExtractArchiveTXT(t *testing.T) { func TestExtractArchiveTXT(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
path := filepath.Join(dir, "sample.txt") path := filepath.Join(dir, "sample.txt")