diff options
Diffstat (limited to 'brokenlinks/worker_test.go')
| -rw-r--r-- | brokenlinks/worker_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/brokenlinks/worker_test.go b/brokenlinks/worker_test.go new file mode 100644 index 0000000..2867338 --- /dev/null +++ b/brokenlinks/worker_test.go @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 M. Shulhan <ms@kilabit.info> + +package brokenlinks + +import ( + "net/url" + "testing" + + "git.sr.ht/~shulhan/pakakeh.go/lib/test" +) + +func TestGenURLRelative(t *testing.T) { + listCase := []struct { + parentURL string + relPath string + expURL string + }{{ + parentURL: `https://domain/a/b/`, + relPath: `c`, + expURL: `https://domain/a/b/c`, + }, { + parentURL: `https://domain/a/b`, + relPath: `c`, + expURL: `https://domain/a/b/c`, + }, { + parentURL: `https://domain/a/b/page.html`, + relPath: `c`, + expURL: `https://domain/a/b/c`, + }, { + parentURL: `https://domain/a/b/page.htm`, + relPath: `c`, + expURL: `https://domain/a/b/c`, + }, { + parentURL: `https://domain/a/b/page.HTML`, + relPath: `c`, + expURL: `https://domain/a/b/c`, + }} + for _, tc := range listCase { + parentURL, _ := url.Parse(tc.parentURL) + got := genURLRelative(parentURL, tc.relPath) + test.Assert(t, ``, tc.expURL, got.String()) + } +} |
