From 176ee616064283f9b3f8156fbb4ad9a8f403793f Mon Sep 17 00:00:00 2001 From: Michael Chus Date: Sat, 12 Sep 2026 16:47:39 +0300 Subject: [PATCH] test: cover archive file selection helpers --- internal/parser/archive_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/internal/parser/archive_test.go b/internal/parser/archive_test.go index 3ac2b85..5403457 100644 --- a/internal/parser/archive_test.go +++ b/internal/parser/archive_test.go @@ -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) { dir := t.TempDir() path := filepath.Join(dir, "sample.txt")