aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/output_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-30 23:44:48 +0900
committerOphestra <cat@gensokyo.uk>2025-08-30 23:44:48 +0900
commit712cfc06d7e541c6e28b4b127a4760b4cfccffa8 (patch)
tree3dbd2bc0fc03ba5d108646b342392f5fdf841c90 /container/output_test.go
parentf5abce9df5727904a1daa246025a87c4bfe62553 (diff)
container: wrap container init start errors
This helps indicate the exact origin and nature of the error. This eliminates generic WrapErr from container. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/output_test.go')
-rw-r--r--container/output_test.go71
1 files changed, 6 insertions, 65 deletions
diff --git a/container/output_test.go b/container/output_test.go
index f6d629e3..85ef756f 100644
--- a/container/output_test.go
+++ b/container/output_test.go
@@ -1,8 +1,6 @@
package container
import (
- "reflect"
- "syscall"
"testing"
)
@@ -31,70 +29,13 @@ func TestGetSetOutput(t *testing.T) {
})
}
-func TestWrapErr(t *testing.T) {
- {
- out := GetOutput()
- t.Cleanup(func() { SetOutput(out) })
- }
-
- var wrapFp *func(error, ...any) error
- s := new(stubOutput)
- SetOutput(s)
- wrapFp = &s.wrapF
-
- testCases := []struct {
- name string
- f func(t *testing.T)
- wantErr error
- wantA []any
- }{
- {"suffix nil", func(t *testing.T) {
- if err := wrapErrSuffix(nil, "\x00"); err != nil {
- t.Errorf("wrapErrSuffix: %v", err)
- }
- }, nil, nil},
- {"suffix val", func(t *testing.T) {
- if err := wrapErrSuffix(syscall.ENOTRECOVERABLE, "\x00\x00"); err != syscall.ENOTRECOVERABLE {
- t.Errorf("wrapErrSuffix: %v", err)
- }
- }, syscall.ENOTRECOVERABLE, []any{"\x00\x00", syscall.ENOTRECOVERABLE}},
- }
-
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- var (
- gotErr error
- gotA []any
- )
- *wrapFp = func(err error, a ...any) error { gotErr = err; gotA = a; return err }
-
- tc.f(t)
- if gotErr != tc.wantErr {
- t.Errorf("WrapErr: err = %v, want %v", gotErr, tc.wantErr)
- }
-
- if !reflect.DeepEqual(gotA, tc.wantA) {
- t.Errorf("WrapErr: a = %v, want %v", gotA, tc.wantA)
- }
- })
- }
-}
-
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) PrintBaseErr(error, string) { panic("unreachable") }
-func (*stubOutput) Suspend() { panic("unreachable") }
-func (*stubOutput) Resume() bool { panic("unreachable") }
-func (*stubOutput) BeforeExit() { panic("unreachable") }
-
-func (s *stubOutput) WrapErr(err error, v ...any) error {
- if s.wrapF == nil {
- panic("unreachable")
- }
- return s.wrapF(err, v...)
-}
+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") }