summaryrefslogtreecommitdiff
path: root/internal/flamegraph/iordata_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-10 19:10:24 +0200
committerPaul Buetow <paul@buetow.org>2026-03-10 19:10:24 +0200
commit8be37dcdc4b8f5d303d034360dedca0136749516 (patch)
treea91f1c6e234804818043ecf293b4e1bbcf49097b /internal/flamegraph/iordata_test.go
parentb4935194b7cdbb9854d7716bd3ec70883358f03a (diff)
task 436: handle loadFromFile close errors
Diffstat (limited to 'internal/flamegraph/iordata_test.go')
-rw-r--r--internal/flamegraph/iordata_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/flamegraph/iordata_test.go b/internal/flamegraph/iordata_test.go
index ee07a90..722cad3 100644
--- a/internal/flamegraph/iordata_test.go
+++ b/internal/flamegraph/iordata_test.go
@@ -3,6 +3,8 @@ package flamegraph
import (
"bytes"
"errors"
+ "os"
+ "path/filepath"
"strings"
"syscall"
"testing"
@@ -328,6 +330,22 @@ func TestSerializeToFileHostnameErrorReturnsError(t *testing.T) {
}
}
+func TestLoadFromFileCorruptDataReturnsContext(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "corrupt.ior.zst")
+ if err := os.WriteFile(path, []byte("not-a-valid-zstd-stream"), 0o600); err != nil {
+ t.Fatalf("write corrupt file: %v", err)
+ }
+
+ iod := newIorData()
+ err := iod.loadFromFile(path)
+ if err == nil {
+ t.Fatal("Expected corrupt file to return an error")
+ }
+ if !strings.Contains(err.Error(), "decode ior records from") {
+ t.Fatalf("Expected decode context, got %v", err)
+ }
+}
+
func bothArraysHaveSameElements(a, b []string) bool {
if len(a) != len(b) {
return false