aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/msg_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/msg_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/msg_test.go')
-rw-r--r--container/msg_test.go43
1 files changed, 0 insertions, 43 deletions
diff --git a/container/msg_test.go b/container/msg_test.go
index 2ad42493..3c68a50e 100644
--- a/container/msg_test.go
+++ b/container/msg_test.go
@@ -1,21 +1,15 @@
package container_test
import (
- "errors"
"log"
"strings"
"sync/atomic"
- "syscall"
"testing"
"hakurei.app/container"
- "hakurei.app/internal/hlog"
)
func TestDefaultMsg(t *testing.T) {
- // bypass WrapErr testing behaviour
- t.Setenv("GOPATH", container.Nonexistent)
-
{
w := log.Writer()
f := log.Flags()
@@ -48,21 +42,6 @@ func TestDefaultMsg(t *testing.T) {
}
})
- t.Run("wrapErr", func(t *testing.T) {
- buf := new(strings.Builder)
- log.SetOutput(buf)
- log.SetFlags(0)
- if err := msg.WrapErr(syscall.EBADE, "\x00", "\x00"); err != syscall.EBADE {
- t.Errorf("WrapErr: %v", err)
- }
- msg.PrintBaseErr(syscall.ENOTRECOVERABLE, "cannot cuddle cat:")
-
- want := "\x00 \x00\ncannot cuddle cat: state not recoverable\n"
- if buf.String() != want {
- t.Errorf("WrapErr: %q, want %q", buf.String(), want)
- }
- })
-
t.Run("inactive", func(t *testing.T) {
{
inactive := msg.Resume()
@@ -83,25 +62,6 @@ func TestDefaultMsg(t *testing.T) {
// the function is a noop
t.Run("beforeExit", func(t *testing.T) { msg.BeforeExit() })
-
- t.Run("checkedWrappedErr", func(t *testing.T) {
- // temporarily re-enable testing behaviour
- t.Setenv("GOPATH", "")
- wrappedErr := msg.WrapErr(syscall.ENOTRECOVERABLE, "cannot cuddle cat:", syscall.ENOTRECOVERABLE)
-
- t.Run("string", func(t *testing.T) {
- want := "state not recoverable, a = [cannot cuddle cat: state not recoverable]"
- if got := wrappedErr.Error(); got != want {
- t.Errorf("Error: %q, want %q", got, want)
- }
- })
-
- t.Run("bad concrete type", func(t *testing.T) {
- if errors.Is(wrappedErr, syscall.ENOTRECOVERABLE) {
- t.Error("incorrect type assertion")
- }
- })
- })
}
type panicWriter struct{}
@@ -139,9 +99,6 @@ func (out *testOutput) Verbosef(format string, v ...any) {
out.t.Logf(format, v...)
}
-func (out *testOutput) WrapErr(err error, a ...any) error { return hlog.WrapErr(err, a...) }
-func (out *testOutput) PrintBaseErr(err error, fallback string) { hlog.PrintBaseError(err, fallback) }
-
func (out *testOutput) Suspend() {
if out.suspended.CompareAndSwap(false, true) {
out.Verbose("suspend called")