mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-05 16:35:45 +00:00
Automated for .go files via gomove [1]: `gomove github.com/containers/podman/v3 github.com/containers/podman/v4` Remaining files via vgrep [2]: `vgrep github.com/containers/podman/v3` [1] https://github.com/KSubedi/gomove [2] https://github.com/vrothberg/vgrep Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
34 lines
823 B
Go
34 lines
823 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/containers/podman/v4/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)
|
|
}
|
|
}
|