MCPcopy
hub / github.com/uber-go/zap / WithStub

Function WithStub

internal/exit/exit.go:51–56  ·  view source on GitHub ↗

WithStub runs the supplied function with Exit stubbed. It returns the stub used, so that users can test whether the process would have crashed.

(f func())

Source from the content-addressed store, hash-verified

49// WithStub runs the supplied function with Exit stubbed. It returns the stub
50// used, so that users can test whether the process would have crashed.
51func WithStub(f func()) *StubbedExit {
52 s := Stub()
53 defer s.Unstub()
54 f()
55 return s
56}
57
58// Unstub restores the previous exit function.
59func (se *StubbedExit) Unstub() {

Callers 7

TestNewStdLogAtFatalFunction · 0.92
TestSugarFatalLoggingFunction · 0.92
TestLoggerLogFatalFunction · 0.92
TestLoggerAlwaysFatalsFunction · 0.92
TestCheckedEntryWriteFunction · 0.92
TestStubFunction · 0.92

Calls 2

StubFunction · 0.85
UnstubMethod · 0.80

Tested by 7

TestNewStdLogAtFatalFunction · 0.74
TestSugarFatalLoggingFunction · 0.74
TestLoggerLogFatalFunction · 0.74
TestLoggerAlwaysFatalsFunction · 0.74
TestCheckedEntryWriteFunction · 0.74
TestStubFunction · 0.74