Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,71 @@
|
||||
package mlogger
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest/observer"
|
||||
)
|
||||
|
||||
func TestNamedAvoidsLoggerNameStutter(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
base string
|
||||
add []any
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "skips duplicate service name",
|
||||
base: "notification",
|
||||
add: []any{"notification"},
|
||||
want: "notification",
|
||||
},
|
||||
{
|
||||
name: "overlaps dotted component",
|
||||
base: "vault",
|
||||
add: []any{"vault.kv"},
|
||||
want: "vault.kv",
|
||||
},
|
||||
{
|
||||
name: "drops child prefix stutter",
|
||||
base: "server.client",
|
||||
add: []any{"client_v2"},
|
||||
want: "server.client.v2",
|
||||
},
|
||||
{
|
||||
name: "keeps already present module name",
|
||||
base: "payments.quotation.server",
|
||||
add: []any{"payments.quotation"},
|
||||
want: "payments.quotation.server",
|
||||
},
|
||||
{
|
||||
name: "extends partial overlap",
|
||||
base: "payments",
|
||||
add: []any{"payments.quotation"},
|
||||
want: "payments.quotation",
|
||||
},
|
||||
{
|
||||
name: "keeps unrelated names",
|
||||
base: "gateway.server",
|
||||
add: []any{"chain", "storage.mongo"},
|
||||
want: "gateway.server.chain.storage.mongo",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
observed, logs := observer.New(zap.InfoLevel)
|
||||
logger := Named(zap.New(observed).Named(tt.base), tt.add...)
|
||||
logger.Info("test")
|
||||
|
||||
entries := logs.All()
|
||||
require.Len(t, entries, 1)
|
||||
require.Equal(t, tt.want, entries[0].LoggerName)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user