ocket8888 commented on code in PR #6892:
URL: https://github.com/apache/trafficcontrol/pull/6892#discussion_r894761487
##########
lib/go-atscfg/remapdotconfig_test.go:
##########
@@ -2085,15 +2085,15 @@ func TestMakeRemapDotConfigEdgeHostRegexReplacement(t
*testing.T) {
txtLines := strings.Split(txt, "\n")
- if len(txtLines) != 3 {
+ if len(txtLines) != 4 {
t.Fatalf("expected 3 remaps from HTTP_AND_HTTPS DS, actual:
'%v' count %v", txt, len(txtLines))
Review Comment:
> What's the confusion here?
I find it confusing when a test tells me "This value should have been X, but
it was X" - that reads like the expectation was satisfied, which leads me to
believe there's something wrong with the test and not my code.
If I make a change to `MakeRemapDotConfig` such that for the same
configuration as given on line 2076 of `remapdotconfig_test.go` it outputs
```
map http://server0.mypattern.cdndomain.example:12080/
origin.example.test/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_0.config
@plugin=url_sig.so @p
param=url_sig_mydsname.config @plugin=cachekey.so @pparam=--separator=
@pparam=--remove-all-params=true @pparam=--remove-path=true
@pparam=--capture-prefix-uri=/^([^?]*)
/$1/ @plugin=regex_remap.so @pparam=regex_remap_mydsname.config
@plugin=cache_range_requests.so myremaptext
map https://server0.mypattern.cdndomain.example:12345/
origin.example.test/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_0.config
@plugin=url_sig.so @
pparam=url_sig_mydsname.config @plugin=cachekey.so @pparam=--separator=
@pparam=--remove-all-params=true @pparam=--remove-path=true
@pparam=--capture-prefix-uri=/^([^?]*
)/$1/ @plugin=regex_remap.so @pparam=regex_remap_mydsname.config
@plugin=cache_range_requests.so myremaptext
```
without a header comment at all, the resulting error message will read
```
=== RUN TestMakeRemapDotConfigEdgeHostRegexReplacement
remapdotconfig_test.go:2089: expected 2 remaps from HTTP_AND_HTTPS DS,
actual: 'map http://server0.mypattern.cdndomain.example:12080/
origin.example.test/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_0.config
@plugin=url_sig.so @p
param=url_sig_mydsname.config @plugin=cachekey.so @pparam=--separator=
@pparam=--remove-all-params=true @pparam=--remove-path=true
@pparam=--capture-prefix-uri=/^([^?]*)
/$1/ @plugin=regex_remap.so @pparam=regex_remap_mydsname.config
@plugin=cache_range_requests.so myremaptext
map https://server0.mypattern.cdndomain.example:12345/
origin.example.test/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_0.config
@plugin=url_sig.so @
pparam=url_sig_mydsname.config @plugin=cachekey.so @pparam=--separator=
@pparam=--remove-all-params=true @pparam=--remove-path=true
@pparam=--capture-prefix-uri=/^([^?]*
)/$1/ @plugin=regex_remap.so @pparam=regex_remap_mydsname.config
@plugin=cache_range_requests.so myremaptext' line count 2
--- FAIL: TestMakeRemapDotConfigEdgeHostRegexReplacement (0.00s)
```
So it
- expected 2 remaps
- got 2 remaps
- on 2 lines
and from that I can't tell what it was supposed to output or why the shown
output is wrong. This testing error message does not contain any information
about why the test failed.
> ... should be obvious from the test code. I guess someone could
potentially be confused if they miss that.
If I have to look at the test code to understand what expectation failed,
then why bother writing an error message at all instead of just outputting the
erroneous value? Which, IMO is a totally valid thing to do and I've done it
many times in Angular unit tests. But outputting a misleading error message is
worse than none at all.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]