test: cover archive file selection helpers
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user