Documentation ¶
Index ¶
- func Substrings(t *testing.T) (h slog.Handler, want func(string))
- type TB
- func (tb *TB) Clear()
- func (tb *TB) Enabled(level slog.Level) bool
- func (tb *TB) Error(args ...any)
- func (tb *TB) Errorf(format string, args ...any)
- func (tb *TB) Fatal(args ...any)
- func (tb *TB) Fatalf(format string, args ...any)
- func (tb *TB) Handle(r slog.Record) error
- func (tb *TB) Log(args ...any)
- func (tb *TB) Logf(format string, args ...any)
- func (tb *TB) Setenv(key, value string)
- func (tb *TB) Skip(args ...any)
- func (tb *TB) Skipf(format string, args ...any)
- func (tb *TB) Want(want string) (found bool)
- func (tb *TB) WantBuffer(want string) (found bool)
- func (tb *TB) WithAttrs(as []slog.Attr) slog.Handler
- func (tb *TB) WithGroup(name string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Substrings ¶
Substrings returns a slog.Handler and a "want" function.
When a logging call is made using the handler, log lines are written to a buffer. Calling "want" tests whether the buffer contains the given string. If it does not, t.Errorf is called. Calling want clears the buffer.
The handler encodes to JSON, and adds source/line information.
Types ¶
type TB ¶
type TB struct { // turns time on / off in logs Time bool // adjust depth Depth int // embed testing.TB, get a lot of free methods... testing.TB // contains filtered or unexported fields }
type TB embeds testing.TB, and has the following utility:
- TB overrides some testing.TB methods, and embeds others - it satisifes the testing.TB interface
- TB also satisfies the slog.Handler interface
- TB provides a method Want, for substring matching of logged output
- TB provides a method WantBuffer, for string matching of logged output
func (*TB) WantBuffer ¶
Click to show internal directories.
Click to hide internal directories.