|
||
---|---|---|
.. | ||
rel | ||
static | ||
found.html | ||
index.html | ||
README.md |
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 existsrel/
- Directory containing a subpage with relative linksindex.html
- Page with relative linksrelfound.html
- Another page that existsimage.jpg
- An image file that exists
static/
- Directory for static assetsstyle.css
- CSS filescript.js
- JavaScript file
Test Cases
This test site is designed to test:
- Working links (internal and external)
- 404 links (missing pages)
- Relative links in subdirectories
- Static assets (CSS, JS, images)
- External links (both working and broken)
Test Suite
The test suite consists of several components:
- Scraper Tests (
pkg/scraper/testsite_test.go
): Tests the core scraper functionality against the testsite. - CLI Tests (
pkg/cli/testsite_test.go
): Tests the CLI interface with the testsite. - Integration Tests (
testsite_test.go
): Full end-to-end tests using the actual binary. - Test Utility (
pkg/testutil/testserver.go
): Helper functions for testing with the testsite. - 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:
- Start a local HTTP server for this test site
- Run the Dharma tool against it
- Verify that the tool correctly identifies the broken and working links
To run the tests:
# 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:
- Add new HTML files or assets to the testsite directory
- Update the test expectations in the test files
- Run the tests to verify they work with the new content