summaryrefslogtreecommitdiff
path: root/tests/papod_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/papod_test.go')
-rw-r--r--tests/papod_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/papod_test.go b/tests/papod_test.go
new file mode 100644
index 0000000..efac1bc
--- /dev/null
+++ b/tests/papod_test.go
@@ -0,0 +1,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)
+}