Files
go-otel/internal/sourcemaps/store_test.go
T
mats 1aa264675e
Build and Publish / Metadata (push) Successful in 2s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m5s
sourcemaps
2026-09-19 16:24:34 +02:00

25 lines
831 B
Go

package sourcemaps
import (
"strings"
"testing"
)
const testMap = `{"version":3,"file":"a.js","sources":["src/a.ts"],"sourcesContent":["const a = 1\nthrow new Error('x')\n"],"names":[],"mappings":"AAAA;AACA"}`
func TestReloadFromDisk(t *testing.T) {
dir := t.TempDir()
r, _ := New(dir)
if err := r.Upload("rel1", "https://h/assets/a.js", strings.NewReader(testMap)); err != nil {
t.Fatal(err)
}
r2, _ := New(dir) // simulates a restart
if l := r2.List(); len(l) != 1 || l[0].Release != "rel1" || l[0].Source != "/assets/a.js" {
t.Fatalf("list after reload = %+v", l)
}
frames := r2.ResolveFrames("rel1", "Error: x\n at f (https://h/assets/a.js:2:1)")
if len(frames) != 1 || frames[0].Status != "mapped" || frames[0].Source != "src/a.ts" || len(frames[0].Context) == 0 {
t.Fatalf("frames = %+v", frames)
}
}