This commit is contained in:
commit
0ef15167d5
28 changed files with 2789 additions and 0 deletions
64
testsite/README.md
Normal file
64
testsite/README.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
# Dharma Test Site
|
||||
|
||||
This directory contains a small test site used for testing the Dharma link checker tool.
|
||||
|
||||
## Structure
|
||||
|
||||
- `index.html` - Main page with various links (some broken)
|
||||
- `found.html` - A page that exists
|
||||
- `rel/` - Directory containing a subpage with relative links
|
||||
- `index.html` - Page with relative links
|
||||
- `relfound.html` - Another page that exists
|
||||
- `image.jpg` - An image file that exists
|
||||
- `static/` - Directory for static assets
|
||||
- `style.css` - CSS file
|
||||
- `script.js` - JavaScript file
|
||||
|
||||
## Test Cases
|
||||
|
||||
This test site is designed to test:
|
||||
|
||||
1. Working links (internal and external)
|
||||
2. 404 links (missing pages)
|
||||
3. Relative links in subdirectories
|
||||
4. Static assets (CSS, JS, images)
|
||||
5. External links (both working and broken)
|
||||
|
||||
## Test Suite
|
||||
|
||||
The test suite consists of several components:
|
||||
|
||||
1. **Scraper Tests** (`pkg/scraper/testsite_test.go`): Tests the core scraper functionality against the testsite.
|
||||
2. **CLI Tests** (`pkg/cli/testsite_test.go`): Tests the CLI interface with the testsite.
|
||||
3. **Integration Tests** (`testsite_test.go`): Full end-to-end tests using the actual binary.
|
||||
4. **Test Utility** (`pkg/testutil/testserver.go`): Helper functions for testing with the testsite.
|
||||
5. **Test Script** (`scripts/test_testsite.sh`): Shell script for manual testing of the tool against the testsite.
|
||||
|
||||
## Usage
|
||||
|
||||
The test site is used by the automated test suite to verify that the Dharma link checker correctly identifies broken and working links. The test suite will:
|
||||
|
||||
1. Start a local HTTP server for this test site
|
||||
2. Run the Dharma tool against it
|
||||
3. Verify that the tool correctly identifies the broken and working links
|
||||
|
||||
To run the tests:
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
go test -v ./...
|
||||
|
||||
# Run tests excluding integration tests
|
||||
go test -v -short ./...
|
||||
|
||||
# Run testsite tests specifically
|
||||
make test-testsite
|
||||
```
|
||||
|
||||
## Adding New Test Cases
|
||||
|
||||
To add new test cases:
|
||||
|
||||
1. Add new HTML files or assets to the testsite directory
|
||||
2. Update the test expectations in the test files
|
||||
3. Run the tests to verify they work with the new content
|
1
testsite/found.html
Normal file
1
testsite/found.html
Normal file
|
@ -0,0 +1 @@
|
|||
found
|
23
testsite/index.html
Normal file
23
testsite/index.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="/found.html">found.html</a> <br>
|
||||
<a href="/not_found.html">not_found.html</a> <br>
|
||||
<a href="/rel/index.html">rel.html</a>
|
||||
<a href="https://fmartingr.com">External link (ok)</a> <br>
|
||||
<a href="http://fmartingr.com">External link (ok - http redir)</a> <br>
|
||||
<a href="https://www.e3H7iaV685rbH7R5lBNxgpietP7JTnMeknmi9SNAEUT4XSiH2sET6ixAcjhy4CAi.com">External link (nack)</a>
|
||||
<br>
|
||||
<script src="/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
0
testsite/rel/image.jpg
Normal file
0
testsite/rel/image.jpg
Normal file
22
testsite/rel/index.html
Normal file
22
testsite/rel/index.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="./relfound.html">found.html</a> <br>
|
||||
<a href="./rel_not_found.html">not_found.html</a> <br>
|
||||
<img src="./image.jpg"> <br>
|
||||
<img src="./image-404.jpg"> <br>
|
||||
<img src="./e3H7iaV685rbH7R5lBNxgpietP7JTnMeknmi9SNAEUT4XSiH2sET6ixAcjhy4CAi"> <br>
|
||||
<br>
|
||||
<script src="/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
1
testsite/rel/relfound.html
Normal file
1
testsite/rel/relfound.html
Normal file
|
@ -0,0 +1 @@
|
|||
found
|
0
testsite/static/script.js
Normal file
0
testsite/static/script.js
Normal file
0
testsite/static/style.css
Normal file
0
testsite/static/style.css
Normal file
Loading…
Add table
Add a link
Reference in a new issue