mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
json: switch backup and restore errors from string to struct types
This keeps backwards compatibility with the previous empty structs. And maybe we'd want to put other fields into the inner struct later, rather than the outer message.
This commit is contained in:
@@ -17,11 +17,11 @@ func createJSONProgress() (*ui.MockTerminal, ProgressPrinter) {
|
||||
func TestJSONError(t *testing.T) {
|
||||
term, printer := createJSONProgress()
|
||||
test.Equals(t, printer.Error("/path", errors.New("error \"message\"")), nil)
|
||||
test.Equals(t, []string{"{\"message_type\":\"error\",\"error\":\"error \\\"message\\\"\",\"during\":\"archival\",\"item\":\"/path\"}\n"}, term.Errors)
|
||||
test.Equals(t, []string{"{\"message_type\":\"error\",\"error\":{\"message\":\"error \\\"message\\\"\"},\"during\":\"archival\",\"item\":\"/path\"}\n"}, term.Errors)
|
||||
}
|
||||
|
||||
func TestJSONScannerError(t *testing.T) {
|
||||
term, printer := createJSONProgress()
|
||||
test.Equals(t, printer.ScannerError("/path", errors.New("error \"message\"")), nil)
|
||||
test.Equals(t, []string{"{\"message_type\":\"error\",\"error\":\"error \\\"message\\\"\",\"during\":\"scan\",\"item\":\"/path\"}\n"}, term.Errors)
|
||||
test.Equals(t, []string{"{\"message_type\":\"error\",\"error\":{\"message\":\"error \\\"message\\\"\"},\"during\":\"scan\",\"item\":\"/path\"}\n"}, term.Errors)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user