mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-21 16:55:06 -05:00
35 lines
715 B
Go
35 lines
715 B
Go
|
// Copyright 2025 The Forgejo Authors.
|
||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
||
|
package log_test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
|
||
|
"code.gitea.io/gitea/modules/log"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestBufferLogger(t *testing.T) {
|
||
|
prefix := "TestPrefix "
|
||
|
level := log.INFO
|
||
|
expected := "something"
|
||
|
|
||
|
bufferWriter := log.NewEventWriterBuffer("test-buffer", log.WriterMode{
|
||
|
Level: level,
|
||
|
Prefix: prefix,
|
||
|
Expression: expected,
|
||
|
})
|
||
|
|
||
|
logger := log.NewLoggerWithWriters(context.Background(), "test", bufferWriter)
|
||
|
|
||
|
logger.SendLogEvent(&log.Event{
|
||
|
Level: log.INFO,
|
||
|
MsgSimpleText: expected,
|
||
|
})
|
||
|
logger.Close()
|
||
|
assert.Contains(t, bufferWriter.Buffer.String(), expected)
|
||
|
}
|