diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-31 11:57:59 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-31 11:57:59 +0900 |
| commit | 780e3e546581dd4a46b887310a665eea06f3279a (patch) | |
| tree | f7186c712fb4e0f62052e147968196bc45a17996 /container/msg_test.go | |
| parent | 712cfc06d7e541c6e28b4b127a4760b4cfccffa8 (diff) | |
container/msg: optionally provide error messages
This makes handling of fatal errors a lot less squirmy.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/msg_test.go')
| -rw-r--r-- | container/msg_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/container/msg_test.go b/container/msg_test.go index 3c68a50e..ba62e9d3 100644 --- a/container/msg_test.go +++ b/container/msg_test.go @@ -1,14 +1,43 @@ package container_test import ( + "errors" "log" "strings" "sync/atomic" + "syscall" "testing" "hakurei.app/container" ) +func TestMessageError(t *testing.T) { + testCases := []struct { + name string + err error + want string + wantOk bool + }{ + {"nil", nil, "", false}, + {"new", errors.New(":3"), "", false}, + {"start", &container.StartError{ + Step: "meow", + Err: syscall.ENOTRECOVERABLE, + }, "cannot meow: state not recoverable", true}, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + got, ok := container.GetErrorMessage(tc.err) + if got != tc.want { + t.Errorf("GetErrorMessage: %q, want %q", got, tc.want) + } + if ok != tc.wantOk { + t.Errorf("GetErrorMessage: ok = %v, want %v", ok, tc.wantOk) + } + }) + } +} + func TestDefaultMsg(t *testing.T) { { w := log.Writer() |
