From a6288d50f2ab73f817d3a890e77146a4dcdd651b Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Mon, 8 Apr 2024 11:50:48 +0400 Subject: [PATCH] test: comment out slogtest.Run Signed-off-by: knqyf263 --- pkg/log/handler_test.go | 48 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg/log/handler_test.go b/pkg/log/handler_test.go index 5d2dcc7267fb..4d3e95c8576c 100644 --- a/pkg/log/handler_test.go +++ b/pkg/log/handler_test.go @@ -11,7 +11,6 @@ import ( "regexp" "strings" "testing" - "testing/slogtest" "time" ) @@ -126,29 +125,30 @@ func stripColorCodes(s string) string { return s } -func TestSlogtest(t *testing.T) { - var buf bytes.Buffer - newHandler := func(*testing.T) slog.Handler { - buf.Reset() - return log.NewHandler(&buf, &log.Options{Level: slog.LevelDebug}) - } - - results := func(*testing.T) map[string]any { - for _, line := range strings.Split(buf.String(), "\n") { - if len(line) == 0 { - continue - } - m, err := parseLogLine(line) - if err != nil { - t.Fatalf("Failed to parse log line: %v", err) - } - return m - } - return nil - } - - slogtest.Run(t, newHandler, results) -} +// TODO: slogtest.Run was added in Go 1.22. Waiting for https://github.com/aquasecurity/trivy/pull/6075. +//func TestSlogtest(t *testing.T) { +// var buf bytes.Buffer +// newHandler := func(*testing.T) slog.Handler { +// buf.Reset() +// return log.NewHandler(&buf, &log.Options{Level: slog.LevelDebug}) +// } +// +// results := func(*testing.T) map[string]any { +// for _, line := range strings.Split(buf.String(), "\n") { +// if len(line) == 0 { +// continue +// } +// m, err := parseLogLine(line) +// if err != nil { +// t.Fatalf("Failed to parse log line: %v", err) +// } +// return m +// } +// return nil +// } +// +// slogtest.Run(t, newHandler, results) +//} func parseLogLine(line string) (map[string]any, error) { parts := strings.SplitN(line, "\t", 4)