Created
November 1, 2023 22:38
-
-
Save jeffmccune/bde347a3f070f57256ee9c037544f436 to your computer and use it in GitHub Desktop.
Revisions
-
jeffmccune created this gist
Nov 1, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ --- FAIL: TestServer (0.00s) --- FAIL: TestServer/NewServer (0.00s) testutils.go:16: DBG identity.go:80: could not get oidc provider err="Get \"/.well-known/openid-configuration\": unsupported protocol scheme \"\"" server_suite_test.go:28: Error Trace: /home/jeff/workspace/holos-run/holos-server-go/internal/server/server_suite_test.go:28 Error: Received unexpected error: Get "/.well-known/openid-configuration": unsupported protocol scheme "" Test: TestServer/NewServer This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ package testutils import ( "fmt" "github.com/lmittmann/tint" "log/slog" "path/filepath" "testing" ) type testWriter struct { t testing.TB } func (w *testWriter) Write(b []byte) (int, error) { w.t.Logf("%s", b) return len(b), nil } // TestLogger is an adapter that sends output to t.Log so that log messages are // associated with failing tests. func TestLogger(t testing.TB) *slog.Logger { t.Helper() testHandler := tint.NewHandler(&testWriter{t}, &tint.Options{ Level: slog.LevelDebug, AddSource: true, ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { if len(groups) == 0 { switch key := a.Key; key { case slog.TimeKey: return slog.Attr{} // Remove the timestamp case slog.SourceKey: if src, ok := a.Value.Any().(*slog.Source); ok { name := fmt.Sprintf("%s:%d:", filepath.Base(src.File), src.Line) return slog.String("source", name) } } } return a }, }) return slog.New(testHandler) }