summaryrefslogtreecommitdiff
path: root/internal/flamegraph/nativejson_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-06 15:35:24 +0200
committerPaul Buetow <paul@buetow.org>2026-03-06 15:35:24 +0200
commit99b02bf8c389a793df5d5986db05eed7e459f7b1 (patch)
treebc4e36cfcd3c9ef9b067beed2eb5b68a75a45aa2 /internal/flamegraph/nativejson_test.go
parent4ff17c30120d657b966f8a55188ba167dc875e64 (diff)
refactor: remove web flamegrapher and keep TUI-only
Diffstat (limited to 'internal/flamegraph/nativejson_test.go')
-rw-r--r--internal/flamegraph/nativejson_test.go75
1 files changed, 0 insertions, 75 deletions
diff --git a/internal/flamegraph/nativejson_test.go b/internal/flamegraph/nativejson_test.go
deleted file mode 100644
index c76d327..0000000
--- a/internal/flamegraph/nativejson_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package flamegraph
-
-import (
- "encoding/json"
- "os"
- "testing"
-)
-
-type jsonNodeForTest struct {
- Name string `json:"name"`
- Value uint64 `json:"value"`
- Total uint64 `json:"total"`
- Children []jsonNodeForTest `json:"children"`
-}
-
-type jsonFlamegraphForTest struct {
- Fields []string `json:"fields"`
- CountField string `json:"countField"`
- Root jsonNodeForTest `json:"root"`
-}
-
-func TestWriteJSONFromFileContainsFlamegraphTree(t *testing.T) {
- dir := t.TempDir()
- iorFile := writeTestIorZst(t, dir)
-
- n := NewNativeSVG([]string{"comm", "path", "tracepoint"}, "count")
- outFile, err := n.WriteJSONFromFile(iorFile)
- if err != nil {
- t.Fatalf("WriteJSONFromFile returned error: %v", err)
- }
-
- data, err := os.ReadFile(outFile)
- if err != nil {
- t.Fatalf("read output json: %v", err)
- }
-
- var payload jsonFlamegraphForTest
- if err := json.Unmarshal(data, &payload); err != nil {
- t.Fatalf("unmarshal output json: %v", err)
- }
-
- if payload.CountField != "count" {
- t.Fatalf("count field = %q, want %q", payload.CountField, "count")
- }
- if len(payload.Fields) != 3 {
- t.Fatalf("fields len = %d, want 3", len(payload.Fields))
- }
- if payload.Root.Name != "root" {
- t.Fatalf("root name = %q, want %q", payload.Root.Name, "root")
- }
- if payload.Root.Total != 1 {
- t.Fatalf("root total = %d, want 1", payload.Root.Total)
- }
- if len(payload.Root.Children) != 1 {
- t.Fatalf("root children len = %d, want 1", len(payload.Root.Children))
- }
- if payload.Root.Children[0].Name != "tester" {
- t.Fatalf("root child name = %q, want %q", payload.Root.Children[0].Name, "tester")
- }
-}
-
-func TestWriteJSONFromFileCleansUpPartialOutputOnError(t *testing.T) {
- dir := t.TempDir()
- iorFile := writeTestIorZst(t, dir)
-
- n := NewNativeSVG([]string{"invalidField"}, "count")
- outFile, err := n.WriteJSONFromFile(iorFile)
- if err == nil {
- t.Fatal("expected error for invalid field, got nil")
- }
-
- if _, statErr := os.Stat(outFile); !os.IsNotExist(statErr) {
- t.Fatalf("expected partial output to be removed, stat err=%v", statErr)
- }
-}