From b1bed38e5e0a261616343c7555962162416c28e2 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 15 Aug 2024 07:24:52 -0300 Subject: src/gobang.go: Add args to Init() to log --- tests/gobang.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/gobang.go') diff --git a/tests/gobang.go b/tests/gobang.go index 842b95a..ef07271 100644 --- a/tests/gobang.go +++ b/tests/gobang.go @@ -1042,6 +1042,26 @@ func test_setLoggerOutput() { ErrorIf(err) }) + Testing("we can add groups to the default logger", func() { + s := new(strings.Builder) + setLoggerOutput(s, slog.Group("one", "key", "value")) + Info("", "") + + var data map[string]interface{} + err := json.Unmarshal([]byte(s.String()), &data) + ErrorIf(err) + + oneRaw, ok := data["one"] + AssertEqual(ok, true) + one, ok := oneRaw.(map[string]interface{}) + AssertEqual(ok, true) + + keyRaw, ok := one["key"] + AssertEqual(ok, true) + key, ok := keyRaw.(string) + AssertEqual(key, "value") + }) + Testing("the puuid is the same across calls to the logger", func() { s := new(strings.Builder) setLoggerOutput(s) -- cgit v1.2.3