github.com/thanos-io/thanos@v0.32.5/pkg/errors/stacktrace_test.go (about) 1 // Copyright (c) The Thanos Authors. 2 // Licensed under the Apache License 2.0. 3 4 package errors 5 6 import ( 7 "strings" 8 "testing" 9 ) 10 11 func caller() stacktrace { 12 return newStackTrace() 13 } 14 15 func TestStacktraceOutput(t *testing.T) { 16 st := caller() 17 expectedPhrase := "/pkg/errors/stacktrace_test.go:16" 18 if !strings.Contains(st.String(), expectedPhrase) { 19 t.Fatalf("expected %v phrase into the stacktrace, received stacktrace: \n%v", expectedPhrase, st.String()) 20 } 21 } 22 23 func TestStacktraceProgramCounterLen(t *testing.T) { 24 st := caller() 25 output := st.String() 26 lines := len(strings.Split(strings.TrimSuffix(output, "\n"), "\n")) 27 if len(st) != lines { 28 t.Fatalf("output lines vs program counter size mismatch: program counter size %v, output lines %v", len(st), lines) 29 } 30 }