forgejo/modules/log/event_writer_buffer_test.go
forgejo-backport-action e286457990 [v11.0/forgejo] chore: branding import path (#7354)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/7337

- Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`.
- Resolves forgejo/discussions#258

Co-authored-by: Gusted <postmaster@gusted.xyz>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7354
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2025-03-27 20:13:05 +00:00

33 lines
687 B
Go

// Copyright 2025 The Forgejo Authors.
// SPDX-License-Identifier: GPL-3.0-or-later
package log_test
import (
"testing"
"forgejo.org/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(t.Context(), "test", bufferWriter)
logger.SendLogEvent(&log.Event{
Level: log.INFO,
MsgSimpleText: expected,
})
logger.Close()
assert.Contains(t, bufferWriter.Buffer.String(), expected)
}