mirror of
https://github.com/alist-org/gofakes3.git
synced 2025-12-24 12:58:04 +08:00
42 lines
732 B
Go
42 lines
732 B
Go
package gofakes3
|
|
|
|
import (
|
|
"bytes"
|
|
"log"
|
|
"testing"
|
|
)
|
|
|
|
func TestStdLog(t *testing.T) {
|
|
var buf bytes.Buffer
|
|
std := log.New(&buf, "", 0)
|
|
l := StdLog(std)
|
|
|
|
l.Print(LogErr, "yep1", 1)
|
|
l.Print(LogErr, "yep2", 2)
|
|
if buf.String() != "ERR yep1 1\nERR yep2 2\n" {
|
|
t.Fatal()
|
|
}
|
|
}
|
|
|
|
func TestStdLogLevels(t *testing.T) {
|
|
var buf bytes.Buffer
|
|
std := log.New(&buf, "", 0)
|
|
l := StdLog(std, LogErr)
|
|
|
|
l.Print(LogErr, "yep1", 1)
|
|
l.Print(LogWarn, "yep2", 2)
|
|
l.Print(LogInfo, "yep3", 3)
|
|
if buf.String() != "ERR yep1 1\n" {
|
|
t.Fatal()
|
|
}
|
|
}
|
|
|
|
func TestDiscardLog(t *testing.T) {
|
|
d := DiscardLog()
|
|
|
|
// if it doesn't panic, that's all we can test!
|
|
d.Print(LogErr, "yep1", 1)
|
|
d.Print(LogWarn, "yep2", 2)
|
|
d.Print(LogInfo, "yep3", 3)
|
|
}
|