mirror of
https://github.com/containers/podman.git
synced 2025-08-24 10:04:57 +08:00

Moving from Go module v4 to v5 prepares us for public releases. Move done using gomove [1] as with the v3 and v4 moves. [1] https://github.com/KSubedi/gomove Signed-off-by: Matt Heon <mheon@redhat.com>
35 lines
817 B
Go
35 lines
817 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/containers/podman/v5/libpod/define"
|
|
)
|
|
|
|
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 := fmt.Errorf("%s: %w", expectedSuffix, define.ErrOCIRuntime)
|
|
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)
|
|
}
|
|
}
|