Skip to content

Commit 75fff69

Browse files
committed
Add comments to tests as requested by @wjdp
1 parent 3c0b4b2 commit 75fff69

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

htmltest/check-link.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ func (hT *HTMLTest) checkMailto(ref *htmldoc.Reference) {
357357

358358
domain := strings.Split(ref.URL.Opaque, "@")[1]
359359

360+
// loop over the current domain until we have a valid result or have exhausted all possibilities
360361
for domain != "" {
361362
// if a simple MX lookup works, we are done, continue
362363
if _, err := net.LookupMX(domain); err == nil {

htmltest/check-link_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,27 +391,32 @@ func TestMailtoInvalidFormat(t *testing.T) {
391391
}
392392

393393
func TestMailtoInvalidCname(t *testing.T) {
394-
// fails for invalid mailto links
394+
// rubdomain with just a CNAME record without MX pointers
395+
// email is still deliverable so should be accepted
396+
// the records have been carefully created to ensure this is valid and will later fall under one of the other
397+
// pass conditions
395398
hT := tTestFile("fixtures/links/invalid_mailto_cname.html")
396399
tExpectIssueCount(t, hT, 0)
397400
}
398401

399402
func TestMailtoInvalidCnameLoop(t *testing.T) {
400-
// fails for invalid mailto links
403+
// subdomain with just a CNAME record without MX records in a loop
404+
// should be detected and fail as we can never resolve this
401405
hT := tTestFile("fixtures/links/invalid_mailto_cname_loop.html")
402406
tExpectIssueCount(t, hT, 1)
403407
tExpectIssue(t, hT, "email domain could not be resolved correctly", 1)
404408
}
405409

406410
func TestMailtoInvalidNoRecords(t *testing.T) {
407-
// fails for invalid mailto links
411+
// domain with no records associated at all, must fail as completely unroutable
408412
hT := tTestFile("fixtures/links/invalid_mailto_norecords.html")
409413
tExpectIssueCount(t, hT, 1)
410414
tExpectIssue(t, hT, "email domain could not be resolved correctly", 1)
411415
}
412416

413417
func TestMailtoInvalidAFallback(t *testing.T) {
414-
// fails for invalid mailto links
418+
// domain without MX records but with a valid A record
419+
// email can be routed to the A record so should be accepted
415420
hT := tTestFile("fixtures/links/invalid_mailto_fallback.html")
416421
tExpectIssueCount(t, hT, 0)
417422
}

0 commit comments

Comments
 (0)