summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-05-06 09:08:22 -0300
committerEuAndreh <eu@euandre.org>2024-05-06 09:08:22 -0300
commitde8599a6d78aa8f46881faa3aafe45918c6baef8 (patch)
treefa501d4ed88ec2be9741539b3b91c5082b46c974 /tests
parentMakefile: Normalize alongside other Go projects (diff)
downloadpapod-de8599a6d78aa8f46881faa3aafe45918c6baef8.tar.gz
papod-de8599a6d78aa8f46881faa3aafe45918c6baef8.tar.xz
src/papo.go: Add initial server skeleton
Diffstat (limited to 'tests')
-rw-r--r--tests/papo_test.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/papo_test.go b/tests/papo_test.go
index f585f57..efac1bc 100644
--- a/tests/papo_test.go
+++ b/tests/papo_test.go
@@ -1,14 +1,37 @@
package papo_test
import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "log/slog"
"testing"
"euandre.org/papo/src"
)
-func TestHello(t *testing.T) {
- if papo.Hello("World") != "Hi, World. Welcome!" {
+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)
}