|
| 1 | +package logger |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/getsentry/sentry-go" |
| 7 | + "github.com/stretchr/testify/assert" |
| 8 | +) |
| 9 | + |
| 10 | +func TestFilterFrames(t *testing.T) { |
| 11 | + rawStacktrace := &sentry.Stacktrace{Frames: []sentry.Frame{ |
| 12 | + { |
| 13 | + Function: "Run.func2", |
| 14 | + Module: "github.com/stretchr/testify/suite", |
| 15 | + AbsPath: "/somewhere/github.com/stretchr/testify/suite/suite.go", |
| 16 | + InApp: true, |
| 17 | + }, |
| 18 | + { |
| 19 | + Function: "Value.Call", |
| 20 | + Module: "reflect", |
| 21 | + AbsPath: "/goroot/src/reflect/value.go", |
| 22 | + InApp: false, |
| 23 | + }, |
| 24 | + { |
| 25 | + Function: "Value.call", |
| 26 | + Module: "reflect", |
| 27 | + AbsPath: "/goroot/src/reflect/value.go", |
| 28 | + InApp: false, |
| 29 | + }, |
| 30 | + { |
| 31 | + Function: "go.pr0ger.dev/logger.(*SentryCoreSuite).TestWriteLevelFieldStoreExtraTags", |
| 32 | + Module: "go.pr0ger.dev/logger", |
| 33 | + AbsPath: "/somewhere/go.pr0ger.dev/logger/sentry_core_test.go", |
| 34 | + InApp: true, |
| 35 | + }, |
| 36 | + { |
| 37 | + Function: "go.uber.org/zap.(*Logger).Error", |
| 38 | + Module: "go.uber.org/zap", |
| 39 | + AbsPath: "/somewhere/go.uber.org/zap/logger.go", |
| 40 | + InApp: true, |
| 41 | + }, |
| 42 | + { |
| 43 | + Function: "go.uber.org/zap/zapcore.(*CheckedEntry).Write", |
| 44 | + Module: "go.uber.org/zap", |
| 45 | + AbsPath: "/somewhere/go.uber.org/zap/zapcore/entry.go", |
| 46 | + InApp: true, |
| 47 | + }, |
| 48 | + { |
| 49 | + Function: "go.pr0ger.dev/logger.(*SentryCore).Write", |
| 50 | + Module: "go.uber.org/zap", |
| 51 | + AbsPath: "/somewhere/go.pr0ger.dev/logger/sentry_core.go", |
| 52 | + InApp: true, |
| 53 | + }, |
| 54 | + { |
| 55 | + Function: "go.pr0ger.dev/logger.newStacktrace", |
| 56 | + Module: "go.pr0ger.dev/logger", |
| 57 | + AbsPath: "/somewhere/go.pr0ger.dev/logger/stacktrace.go", |
| 58 | + InApp: true, |
| 59 | + }, |
| 60 | + }} |
| 61 | + filteredStacktrace := &sentry.Stacktrace{Frames: []sentry.Frame{ |
| 62 | + { |
| 63 | + Function: "Run.func2", |
| 64 | + Module: "github.com/stretchr/testify/suite", |
| 65 | + AbsPath: "/somewhere/github.com/stretchr/testify/suite/suite.go", |
| 66 | + InApp: true, |
| 67 | + }, |
| 68 | + { |
| 69 | + Function: "Value.Call", |
| 70 | + Module: "reflect", |
| 71 | + AbsPath: "/goroot/src/reflect/value.go", |
| 72 | + InApp: false, |
| 73 | + }, |
| 74 | + { |
| 75 | + Function: "Value.call", |
| 76 | + Module: "reflect", |
| 77 | + AbsPath: "/goroot/src/reflect/value.go", |
| 78 | + InApp: false, |
| 79 | + }, |
| 80 | + { |
| 81 | + Function: "go.pr0ger.dev/logger.(*SentryCoreSuite).TestWriteLevelFieldStoreExtraTags", |
| 82 | + Module: "go.pr0ger.dev/logger", |
| 83 | + AbsPath: "/somewhere/go.pr0ger.dev/logger/sentry_core_test.go", |
| 84 | + InApp: true, |
| 85 | + }, |
| 86 | + }} |
| 87 | + |
| 88 | + assert.Equal(t, filteredStacktrace, filterFrames(rawStacktrace)) |
| 89 | +} |
0 commit comments