aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/msg_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'container/msg_test.go')
-rw-r--r--container/msg_test.go29
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()