Skip to content

Commit

Permalink
test schema URL in NewHook
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Apr 25, 2024
1 parent 235024e commit 3649217
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion bridges/otellogrus/hook_test.go
Expand Up @@ -102,7 +102,42 @@ func TestNewConfig(t *testing.T) {
}

func TestNewHook(t *testing.T) {
assert.NotNil(t, NewHook())
provider := global.GetLoggerProvider()

for _, tt := range []struct {
name string
options []Option

wantLogger log.Logger
}{
{
name: "with the default options",

wantLogger: provider.Logger(bridgeName, log.WithInstrumentationVersion(version)),
},
{
name: "with a schema URL",
options: []Option{
WithInstrumentationScope(instrumentation.Scope{
Name: "test",
Version: "42.1",
SchemaURL: "https://example.com",
}),
},

wantLogger: provider.Logger("test",
log.WithInstrumentationVersion("42.1"),
log.WithSchemaURL("https://example.com"),
),
},
} {
t.Run(tt.name, func(t *testing.T) {
hook := NewHook(tt.options...)
assert.NotNil(t, hook)

assert.Equal(t, tt.wantLogger, hook.logger)
})
}
}

func TestHookLevels(t *testing.T) {
Expand Down

0 comments on commit 3649217

Please sign in to comment.