Updates to tests

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2022-09-06 11:10:10 -07:00
parent b850a95d4c
commit 9c3bd17059
7 changed files with 79 additions and 65 deletions

View File

@@ -98,8 +98,15 @@ func require_Error(t *testing.T, err error, expected ...error) {
if len(expected) == 0 {
return
}
// Try to strip nats prefix from Go library if present.
const natsErrPre = "nats: "
eStr := err.Error()
if strings.HasPrefix(eStr, natsErrPre) {
eStr = strings.Replace(eStr, natsErrPre, _EMPTY_, 1)
}
for _, e := range expected {
if err == e || strings.Contains(e.Error(), err.Error()) {
if err == e || strings.Contains(e.Error(), eStr) {
return
}
}