dfdr/TESTING.md

111 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2025-11-29 07:35:29 +01:00
# Testing dfdr
This document outlines the test cases for verifying the functionality of the dfdr tool.
## Test Cases
### 1. Relative Paths for Registry List
- Add a registry using a relative path:
```
dfdr registry add test_registry ../test_data
```
- List registries and verify the path is displayed as relative:
```
dfdr registry list
```
- Use the registry to add a file:
```
dfdr add test_registry:sample.txt
```
### 2. Specifying Destination Subdirectories
- Add a file to a specific subdirectory:
```
dfdr add test_registry:sample.txt -d ./subfolder
```
- Verify the file is placed in the correct location:
```
ls ./subfolder
```
- Check that the .dfdr file contains the correct origin information:
```
cat ./subfolder/sample.txt.dfdr
```
### 3. Enhanced .dfdr Files with Origin Information
- Add a file from a registry:
```
dfdr add test_registry:config.json
```
- Examine the .dfdr file:
```
cat config.json.dfdr
```
- Use the `status` command to verify the origin information:
```
dfdr status
```
### 4. Push Functionality
- Add a file from a registry:
```
dfdr add test_registry:data.csv
```
- Modify the file in the working copy:
```
echo "new data" >> data.csv
```
- Push changes back to the registry:
```
dfdr push data.csv
```
- Verify changes in the original registry:
```
cat ../test_data/data.csv
```
### 5. Move Command
- Add a file from a registry:
```
dfdr add test_registry:script.py
```
- Move the file within the working copy:
```
dfdr move script.py ./src/script.py
```
- Verify the file is moved and .dfdr file is updated:
```
ls ./src
cat ./src/script.py.dfdr
```
- Check status for correct location and origin information:
```
dfdr status
```
### 6. Error Handling
- Attempt to push a non-existent file:
```
dfdr push non_existent_file.txt
```
- Try to move a file to an invalid destination:
```
dfdr move script.py /root/invalid_destination.py
```
- Add a file from a non-existent registry:
```
dfdr add fake_registry:file.txt
```
## Running the Tests
To run these tests, set up a test environment with a sample data registry, then execute each command and verify the results match the expected behavior.
Remember to clean up the test environment after running the tests to ensure a clean state for future test runs.