diff options
Diffstat (limited to 'internal/flamegraph/iordata_test.go')
| -rw-r--r-- | internal/flamegraph/iordata_test.go | 18 |
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 |
