forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the "err: cause" order of OCI runtime errors
Previously, the order of OCI error messages was reversed, so that the type of error was listed as the cause. For example: Error: writing file `cpu.cfs_quota_us`: Invalid argument: OCI runtime error This error message makes it seem like "OCI runtime error" is the argument that was invalid. In fact, "OCI runtime error" is the error and "writing file ..." is the cause. With this change, the above message reads: Error: OCI runtime error: writing file `cpu.cfs_quota_us`: Invalid argument Signed-off-by: Jordan Christiansen <[email protected]>
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |