summaryrefslogtreecommitdiff
path: root/cmd/podman/root_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-09 15:24:58 -0400
committerGitHub <noreply@github.com>2020-10-09 15:24:58 -0400
commitcec240375d6dceb09c705d6d55e67aeff037327f (patch)
treeee290e59ed69988c7ad09d8a60a78ef3f284f0c5 /cmd/podman/root_test.go
parentffabd57d6de01c5c65b2e2291b6a6564d28263a0 (diff)
parentc47a1b1e550a361a009156e14fcc933dfbbdee64 (diff)
downloadpodman-cec240375d6dceb09c705d6d55e67aeff037327f.tar.gz
podman-cec240375d6dceb09c705d6d55e67aeff037327f.tar.bz2
podman-cec240375d6dceb09c705d6d55e67aeff037327f.zip
Merge pull request #7968 from xordspar0/oci-runtime-error
Print the correct underlying cause for OCI errors
Diffstat (limited to 'cmd/podman/root_test.go')
-rw-r--r--cmd/podman/root_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/cmd/podman/root_test.go b/cmd/podman/root_test.go
new file mode 100644
index 000000000..0473128df
--- /dev/null
+++ b/cmd/podman/root_test.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "fmt"
+ "strings"
+ "testing"
+
+ "github.com/containers/podman/v2/libpod/define"
+ "github.com/pkg/errors"
+)
+
+func TestFormatError(t *testing.T) {
+ err := errors.New("unknown error")
+ output := formatError(err)
+ expected := fmt.Sprintf("Error: %v", err)
+
+ if output != expected {
+ t.Errorf("Expected \"%s\" to equal \"%s\"", output, err.Error())
+ }
+}
+
+func TestFormatOCIError(t *testing.T) {
+ expectedPrefix := "Error: "
+ expectedSuffix := "OCI runtime output"
+ err := errors.Wrap(define.ErrOCIRuntime, expectedSuffix)
+ output := formatError(err)
+
+ if !strings.HasPrefix(output, expectedPrefix) {
+ t.Errorf("Expected \"%s\" to start with \"%s\"", output, expectedPrefix)
+ }
+ if !strings.HasSuffix(output, expectedSuffix) {
+ t.Errorf("Expected \"%s\" to end with \"%s\"", output, expectedSuffix)
+ }
+}