All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 1m59s
Test / Hakurei (push) Successful in 3m20s
Test / Sandbox (race detector) (push) Successful in 4m26s
Test / Hpkg (push) Successful in 3m47s
Test / Hakurei (race detector) (push) Successful in 5m21s
Test / Flake checks (push) Successful in 1m35s
This helps indicate the exact origin and nature of the error. This eliminates generic WrapErr from container. Signed-off-by: Ophestra <cat@gensokyo.uk>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package container
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestGetSetOutput(t *testing.T) {
|
|
{
|
|
out := GetOutput()
|
|
t.Cleanup(func() { SetOutput(out) })
|
|
}
|
|
|
|
t.Run("default", func(t *testing.T) {
|
|
SetOutput(new(stubOutput))
|
|
if v, ok := GetOutput().(*DefaultMsg); ok {
|
|
t.Fatalf("SetOutput: got unexpected output %#v", v)
|
|
}
|
|
SetOutput(nil)
|
|
if _, ok := GetOutput().(*DefaultMsg); !ok {
|
|
t.Fatalf("SetOutput: got unexpected output %#v", GetOutput())
|
|
}
|
|
})
|
|
|
|
t.Run("stub", func(t *testing.T) {
|
|
SetOutput(new(stubOutput))
|
|
if _, ok := GetOutput().(*stubOutput); !ok {
|
|
t.Fatalf("SetOutput: got unexpected output %#v", GetOutput())
|
|
}
|
|
})
|
|
}
|
|
|
|
type stubOutput struct {
|
|
wrapF func(error, ...any) error
|
|
}
|
|
|
|
func (*stubOutput) IsVerbose() bool { panic("unreachable") }
|
|
func (*stubOutput) Verbose(...any) { panic("unreachable") }
|
|
func (*stubOutput) Verbosef(string, ...any) { panic("unreachable") }
|
|
func (*stubOutput) Suspend() { panic("unreachable") }
|
|
func (*stubOutput) Resume() bool { panic("unreachable") }
|
|
func (*stubOutput) BeforeExit() { panic("unreachable") }
|