From bb27f7408c1c90e0e0fca579c76de46bf49b3575 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 18 Aug 2022 20:14:09 +0200 Subject: [PATCH] forget: Fail test if duration parsing error is missing --- changelog/unreleased/issue-3861 | 1 + internal/restic/duration_test.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/changelog/unreleased/issue-3861 b/changelog/unreleased/issue-3861 index 3d399df0b..501f6c83b 100644 --- a/changelog/unreleased/issue-3861 +++ b/changelog/unreleased/issue-3861 @@ -6,3 +6,4 @@ units in the duration options, such as e.g. `--keep-within-daily 2w`. Specifying an invalid/unsupported duration unit now results in an error. https://github.com/restic/restic/issues/3861 +https://github.com/restic/restic/pull/3862 diff --git a/internal/restic/duration_test.go b/internal/restic/duration_test.go index b46fc66be..f03aa5553 100644 --- a/internal/restic/duration_test.go +++ b/internal/restic/duration_test.go @@ -83,8 +83,14 @@ func TestParseDuration(t *testing.T) { for _, test := range tests { t.Run("", func(t *testing.T) { d, err := ParseDuration(test.input) - if err != nil && !test.err { - t.Fatal(err) + if test.err { + if err == nil { + t.Fatalf("Missing error for %v", test.input) + } + } else { + if err != nil { + t.Fatal(err) + } } if !cmp.Equal(d, test.d) {