64 lines
2 KiB
Markdown
64 lines
2 KiB
Markdown
# 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
|