blob: efac1bc0e7a0b2da933318056ba0f93899836d4f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package papo_test
import (
"bytes"
"encoding/json"
"fmt"
"log/slog"
"testing"
"euandre.org/papo/src"
)
func TestSetLoggerOutput(t *testing.T) {
return
type entry struct {
msg string `json:"msg"`
aKey string `json:"a-key"`
}
var e entry
var buf bytes.Buffer
papo.SetLoggerOutput(&buf)
slog.Error("the message", "a-key", "a-value")
s := buf.String()
// fmt.Println(s)
// fmt.Println(e)
err := json.Unmarshal([]byte(s), &e)
if err != nil {
t.Fail()
}
if e.msg != "the message" {
t.Fail()
}
fmt.Println(1)
// fmt.Println(e)
}
|