Skip to content

Commit b5b2d79

Browse files
albertteohalbertteoh
and
albertteoh
authored
Fix error equals (#2429)
* Fix broken test in go 1.15 Signed-off-by: albertteoh <[email protected]> * More explicit and specific assertions Signed-off-by: albertteoh <[email protected]> Co-authored-by: albertteoh <[email protected]>
1 parent 4062992 commit b5b2d79

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: cmd/query/app/query_parser_test.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
package app
1717

1818
import (
19+
"fmt"
1920
"net/http"
21+
"regexp"
2022
"testing"
2123
"time"
2224

2325
"github.com/kr/pretty"
2426
"github.com/stretchr/testify/assert"
27+
"github.com/stretchr/testify/require"
2528

2629
"github.com/jaegertracing/jaeger/model"
2730
"github.com/jaegertracing/jaeger/storage/spanstore"
@@ -41,8 +44,8 @@ func TestParseTraceQuery(t *testing.T) {
4144
{"x?service=service&start=string", errParseInt, nil},
4245
{"x?service=service&end=string", errParseInt, nil},
4346
{"x?service=service&limit=string", errParseInt, nil},
44-
{"x?service=service&start=0&end=0&operation=operation&limit=200&minDuration=20", "cannot not parse minDuration: time: missing unit in duration 20", nil},
45-
{"x?service=service&start=0&end=0&operation=operation&limit=200&minDuration=20s&maxDuration=30", "cannot not parse maxDuration: time: missing unit in duration 30", nil},
47+
{"x?service=service&start=0&end=0&operation=operation&limit=200&minDuration=20", `cannot not parse minDuration: time: missing unit in duration "?20"?$`, nil},
48+
{"x?service=service&start=0&end=0&operation=operation&limit=200&minDuration=20s&maxDuration=30", `cannot not parse maxDuration: time: missing unit in duration "?30"?$`, nil},
4649
{"x?service=service&start=0&end=0&operation=operation&limit=200&tag=k:v&tag=x:y&tag=k&log=k:v&log=k", `malformed 'tag' parameter, expecting key:value, received: k`, nil},
4750
{"x?service=service&start=0&end=0&operation=operation&limit=200&minDuration=25s&maxDuration=1s", `'maxDuration' should be greater than 'minDuration'`, nil},
4851
{"x?service=service&start=0&end=0&operation=operation&limit=200&tag=k:v&tag=x:y", noErr,
@@ -161,7 +164,9 @@ func TestParseTraceQuery(t *testing.T) {
161164
}
162165
}
163166
} else {
164-
assert.EqualError(t, err, test.errMsg)
167+
matched, matcherr := regexp.MatchString(test.errMsg, err.Error())
168+
require.NoError(t, matcherr)
169+
assert.True(t, matched, fmt.Sprintf("Error \"%s\" should match \"%s\"", err.Error(), test.errMsg))
165170
}
166171
})
167172
}

0 commit comments

Comments
 (0)