aboutsummaryrefslogtreecommitdiff
path: root/brokenlinks/brokenlinks_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-02-12 01:04:40 +0700
committerShulhan <ms@kilabit.info>2026-02-12 01:04:40 +0700
commit9c7ee77376294e9abd70ca356e26d0ab16ad7466 (patch)
tree2fc279d233575571389ea89d2ba0be16314bc7dd /brokenlinks/brokenlinks_test.go
parent8100b3be0730173a77f1a64f9ac6bc8862a159ac (diff)
downloadjarink-9c7ee77376294e9abd70ca356e26d0ab16ad7466.tar.xz
brokenlinks: store the anchor or image source in link
In the struct Link, we add field Value that store the href from A element or src from IMG element. This allow us to debug any error during scan, especially joining path and link.
Diffstat (limited to 'brokenlinks/brokenlinks_test.go')
-rw-r--r--brokenlinks/brokenlinks_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/brokenlinks/brokenlinks_test.go b/brokenlinks/brokenlinks_test.go
index ab857cd..460e5ac 100644
--- a/brokenlinks/brokenlinks_test.go
+++ b/brokenlinks/brokenlinks_test.go
@@ -281,16 +281,19 @@ func TestScan(t *testing.T) {
testUrl + `/`: []jarink.Link{
{
ParentUrl: parsedTestUrl,
+ Value: `/broken.png`,
Url: testUrl + `/broken.png`,
StatusCode: http.StatusNotFound,
Kind: int(atom.Img),
}, {
ParentUrl: parsedTestUrl,
+ Value: `/brokenPage`,
Url: testUrl + `/brokenPage`,
StatusCode: http.StatusNotFound,
Kind: int(atom.A),
}, {
ParentUrl: parsedTestUrl,
+ Value: `http://127.0.0.1:abc`,
Url: `http://127.0.0.1:abc`,
ErrScan: errScanPort,
Error: `parse "http://127.0.0.1:abc": invalid port ":abc" after host`,
@@ -298,6 +301,7 @@ func TestScan(t *testing.T) {
Kind: int(atom.A),
}, {
ParentUrl: parsedTestUrl,
+ Value: `http:/127.0.0.1:11836`,
Url: `http:/127.0.0.1:11836`,
ErrScan: &url.Error{
Op: `Get`,
@@ -310,6 +314,7 @@ func TestScan(t *testing.T) {
IsExternal: true,
}, {
ParentUrl: parsedTestUrl,
+ Value: `https://domain`,
Url: `https://domain`,
ErrScan: &url.Error{
Op: `Get`,
@@ -333,6 +338,7 @@ func TestScan(t *testing.T) {
testUrl + `/broken.html`: []jarink.Link{
{
ParentUrl: parsedUrlBrokenHtml,
+ Value: `/brokenPage`,
Url: testUrl + `/brokenPage`,
StatusCode: http.StatusNotFound,
Kind: int(atom.A),
@@ -341,16 +347,19 @@ func TestScan(t *testing.T) {
testUrl + `/page2/`: []jarink.Link{
{
ParentUrl: parsedUrlPage2,
+ Value: `/broken.png`,
Url: testUrl + `/broken.png`,
StatusCode: http.StatusNotFound,
Kind: int(atom.Img),
}, {
ParentUrl: parsedUrlPage2,
+ Value: `broken/relative`,
Url: testUrl + `/page2/broken/relative`,
StatusCode: http.StatusNotFound,
Kind: int(atom.A),
}, {
ParentUrl: parsedUrlPage2,
+ Value: `broken2.png`,
Url: testUrl + `/page2/broken2.png`,
StatusCode: http.StatusNotFound,
Kind: int(atom.Img),
@@ -368,17 +377,20 @@ func TestScan(t *testing.T) {
testUrl + `/page2/`: []jarink.Link{
{
ParentUrl: parsedUrlPage2,
+ Value: `/broken.png`,
Url: testUrl + `/broken.png`,
StatusCode: http.StatusNotFound,
Kind: int(atom.Img),
IsExternal: true,
}, {
ParentUrl: parsedUrlPage2,
+ Value: `broken/relative`,
Url: testUrl + `/page2/broken/relative`,
StatusCode: http.StatusNotFound,
Kind: int(atom.A),
}, {
ParentUrl: parsedUrlPage2,
+ Value: `broken2.png`,
Url: testUrl + `/page2/broken2.png`,
StatusCode: http.StatusNotFound,
Kind: int(atom.Img),
@@ -442,17 +454,20 @@ func TestScan_pastResult(t *testing.T) {
testUrl + `/page2/`: []jarink.Link{
{
ParentUrl: parsedUrlPage2,
+ Value: `/broken.png`,
Url: testUrl + `/broken.png`,
StatusCode: http.StatusNotFound,
Kind: int(atom.Img),
IsExternal: true,
}, {
ParentUrl: parsedUrlPage2,
+ Value: `broken/relative`,
Url: testUrl + `/page2/broken/relative`,
StatusCode: http.StatusNotFound,
Kind: int(atom.A),
}, {
ParentUrl: parsedUrlPage2,
+ Value: `broken2.png`,
Url: testUrl + `/page2/broken2.png`,
StatusCode: http.StatusNotFound,
Kind: int(atom.Img),