MCPcopy Index your code
hub / github.com/coder/slog / TestExit

Function TestExit

slog_exit_test.go:10–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestExit(t *testing.T) {
11 // This can't be parallel since it modifies a global variable.
12 t.Run("defaultExitFn", func(t *testing.T) {
13 var (
14 ctx = context.Background()
15 log Logger
16 defaultExitFnCalled bool
17 )
18
19 prevExitFn := defaultExitFn
20 t.Cleanup(func() { defaultExitFn = prevExitFn })
21
22 defaultExitFn = func(_ int) {
23 defaultExitFnCalled = true
24 }
25
26 log.Debug(ctx, "hi")
27 log.Info(ctx, "hi")
28 log.Warn(ctx, "hi")
29 log.Error(ctx, "hi")
30 log.Critical(ctx, "hi")
31 log.Fatal(ctx, "hi")
32
33 assert.True(t, "default exit fn used", defaultExitFnCalled)
34 })
35}

Callers

nothing calls this directly

Calls 8

TrueFunction · 0.92
CleanupMethod · 0.80
DebugMethod · 0.80
InfoMethod · 0.80
WarnMethod · 0.80
CriticalMethod · 0.80
ErrorMethod · 0.45
FatalMethod · 0.45

Tested by

no test coverage detected