feat_: endpoint for testing panic reports (#6126)

* feat_: endpoint for testing panic reports

* test_: TestIntendedPanic

* fix_: linter
This commit is contained in:
Igor Sirotin 2024-11-29 10:33:36 +00:00 committed by GitHub
parent 9bc514805d
commit 81bd17ca01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -2261,3 +2261,13 @@ func addCentralizedMetric(requestJSON string) string {
return metric.ID
}
func IntendedPanic(message string) string {
type intendedPanic struct {
error
}
return callWithResponse(func() {
err := intendedPanic{error: errors.New(message)}
panic(err)
})
}

View File

@ -6,6 +6,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/brianvoe/gofakeit/v6"
"github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/multiaccounts/settings"
"github.com/status-im/status-go/signal"
@ -38,3 +40,10 @@ func TestSetMobileSignalHandler(t *testing.T) {
require.Contains(t, handler.receivedSignal, `"name":"test"`, "Signal should contain the correct account name")
require.Contains(t, handler.receivedSignal, `"ensUsernames":{"test":"test"}`, "Signal should contain the correct ENS usernames")
}
func TestIntendedPanic(t *testing.T) {
message := gofakeit.LetterN(5)
require.PanicsWithError(t, message, func() {
IntendedPanic(message)
})
}