28 lines
576 B
Go
28 lines
576 B
Go
|
|
package starlog
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func resetLoggerAsyncRuntimeForTest(t *testing.T, logger *StarLogger) *asyncRuntime {
|
||
|
|
t.Helper()
|
||
|
|
if logger == nil {
|
||
|
|
t.Fatal("logger is nil")
|
||
|
|
}
|
||
|
|
runtime := logger.asyncRuntime()
|
||
|
|
runtime.resetForTest()
|
||
|
|
t.Cleanup(runtime.resetForTest)
|
||
|
|
return runtime
|
||
|
|
}
|
||
|
|
|
||
|
|
func setAsyncRuntimeStateForTest(runtime *asyncRuntime, queue *starChanStack, started bool) {
|
||
|
|
if runtime == nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
runtime.Stop()
|
||
|
|
runtime.mu.Lock()
|
||
|
|
runtime.queue = queue
|
||
|
|
runtime.started = started
|
||
|
|
runtime.stopChan = nil
|
||
|
|
runtime.doneChan = nil
|
||
|
|
runtime.mu.Unlock()
|
||
|
|
}
|