mirror of
https://github.com/restic/restic.git
synced 2025-08-11 09:57:45 +00:00
errors: Ensure that errors.IsFatal(errors.Fatal("err")) == true
This fixes a few cases where restic output "Fatal: Fatal: [...]"
This commit is contained in:
22
internal/errors/fatal_test.go
Normal file
22
internal/errors/fatal_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package errors_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/internal/errors"
|
||||
)
|
||||
|
||||
func TestFatal(t *testing.T) {
|
||||
for _, v := range []struct {
|
||||
err error
|
||||
expected bool
|
||||
}{
|
||||
{errors.Fatal("broken"), true},
|
||||
{errors.Fatalf("broken %d", 42), true},
|
||||
{errors.New("error"), false},
|
||||
} {
|
||||
if errors.IsFatal(v.err) != v.expected {
|
||||
t.Fatalf("IsFatal for %q, expected: %v, got: %v", v.err, v.expected, errors.IsFatal(v.err))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user