-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_info_test.go
34 lines (25 loc) · 989 Bytes
/
error_info_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package goapperrors
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_InfoBuilderOption(t *testing.T) {
buildConfig := &InfoBuilderConfig{}
InfoBuilderOptionCustomBuilder(func(AppError, *InfoBuilderConfig) *InfoBuilderResult {
return &InfoBuilderResult{}
})(buildConfig)
assert.NotNil(t, buildConfig.InfoBuilderFunc)
errConfig := ErrorConfig{}
InfoBuilderOptionCustomConfig(errConfig)(buildConfig)
assert.Equal(t, errConfig, buildConfig.ErrorConfig)
InfoBuilderOptionTranslationFunc(func(Language, string, map[string]any) (string, error) {
return "", nil
})(buildConfig)
assert.NotNil(t, buildConfig.TranslationFunc)
InfoBuilderOptionTranslateTitle(true)(buildConfig)
assert.True(t, buildConfig.TranslateTitle)
InfoBuilderOptionSeparator("abc123")(buildConfig)
assert.Equal(t, "abc123", buildConfig.ErrorSeparator)
InfoBuilderOptionFallbackContent(true)(buildConfig)
assert.True(t, buildConfig.FallbackToErrorContentOnMissingTranslation)
}