mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-09-01 03:31:25 +02:00
fix: polish non-blocking console logger tests
Co-authored-by: jkroepke <1560587+jkroepke@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7ec2eee6d3
commit
d2d532e24d
@@ -54,8 +54,6 @@ func newNonBlockingWriter(writer io.Writer, queueSize int) *nonBlockingWriter {
|
||||
}
|
||||
|
||||
func (w *nonBlockingWriter) Write(p []byte) (int, error) {
|
||||
msg := bytes.Clone(p)
|
||||
|
||||
w.mu.RLock()
|
||||
defer w.mu.RUnlock()
|
||||
|
||||
@@ -63,6 +61,8 @@ func (w *nonBlockingWriter) Write(p []byte) (int, error) {
|
||||
return 0, io.ErrClosedPipe
|
||||
}
|
||||
|
||||
msg := bytes.Clone(p)
|
||||
|
||||
select {
|
||||
case w.queue <- msg:
|
||||
default:
|
||||
|
||||
@@ -111,6 +111,8 @@ func TestNonBlockingWriterDropsInsteadOfBlocking(t *testing.T) {
|
||||
require.Len(t, writes, 2)
|
||||
require.Equal(t, []byte("first"), writes[0])
|
||||
require.Equal(t, []byte("second"), writes[1])
|
||||
require.NotEqual(t, []byte("third"), writes[0])
|
||||
require.NotEqual(t, []byte("third"), writes[1])
|
||||
|
||||
for _, write := range writes {
|
||||
require.NotEqual(t, []byte("third"), write)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user