options: Fix test for Go >= 1.15

This commit is contained in:
Alexander Neumann 2020-09-12 17:36:44 +02:00
parent 59fca85844
commit 97950ab81a
1 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package options
import (
"fmt"
"reflect"
"regexp"
"testing"
"time"
)
@ -199,7 +200,7 @@ var invalidSetTests = []struct {
"timeout": "2134",
},
"ns",
`time: missing unit in duration 2134`,
`time: missing unit in duration "?2134"?`,
},
}
@ -212,8 +213,13 @@ func TestOptionsApplyInvalid(t *testing.T) {
t.Fatalf("expected error %v not found", test.err)
}
if err.Error() != test.err {
t.Fatalf("expected error %q, got %q", test.err, err.Error())
matched, err := regexp.MatchString(test.err, err.Error())
if err != nil {
t.Fatal(err)
}
if !matched {
t.Fatalf("expected error to match %q, got %q", test.err, err.Error())
}
})
}