Skip to content

Commit c2327e1

Browse files
committed
add tests and update the README
1 parent c6d2f12 commit c2327e1

File tree

6 files changed

+998
-0
lines changed

6 files changed

+998
-0
lines changed

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,107 @@ The tool provides detailed error messages for common issues:
441441
4. **Memory**: Tool streams data to minimize memory usage
442442
5. **Compression**: Multi-core zstd scales with CPU cores
443443

444+
## 🧪 Testing
445+
446+
The project includes a comprehensive test suite covering:
447+
448+
- **Cache Operations**: Row count and file metadata caching, TTL expiration, legacy migration
449+
- **Configuration Validation**: Required fields, default values, date formats
450+
- **Process Management**: PID file operations, task tracking, process status checks
451+
452+
Run tests with:
453+
454+
```bash
455+
# Run all tests
456+
go test ./...
457+
458+
# Run with verbose output
459+
go test -v ./...
460+
461+
# Run with coverage
462+
go test -cover ./...
463+
464+
# Run specific tests
465+
go test -run TestPartitionCache ./cmd
466+
```
467+
468+
## 🐳 Docker Support
469+
470+
Build and run with Docker:
471+
472+
```bash
473+
# Build the Docker image
474+
docker build -t postgresql-archiver .
475+
476+
# Run with environment variables
477+
docker run --rm \
478+
-e ARCHIVE_DB_HOST=host.docker.internal \
479+
-e ARCHIVE_DB_USER=myuser \
480+
-e ARCHIVE_DB_PASSWORD=mypass \
481+
-e ARCHIVE_DB_NAME=mydb \
482+
-e ARCHIVE_S3_ENDPOINT=https://s3.example.com \
483+
-e ARCHIVE_S3_BUCKET=my-bucket \
484+
-e ARCHIVE_S3_ACCESS_KEY=key \
485+
-e ARCHIVE_S3_SECRET_KEY=secret \
486+
-e ARCHIVE_TABLE=events \
487+
postgresql-archiver
488+
489+
# Run with config file
490+
docker run --rm \
491+
-v ~/.postgresql-archiver.yaml:/root/.postgresql-archiver.yaml \
492+
postgresql-archiver
493+
```
494+
495+
## 🔧 Development
496+
497+
### Prerequisites
498+
499+
- Go 1.21+
500+
- PostgreSQL database for testing
501+
- S3-compatible storage for testing
502+
503+
### Building from Source
504+
505+
```bash
506+
# Clone the repository
507+
git clone https://github.com/airframesio/postgresql-archiver.git
508+
cd postgresql-archiver
509+
510+
# Install dependencies
511+
go mod download
512+
513+
# Build the binary
514+
go build -o postgresql-archiver
515+
516+
# Run tests
517+
go test ./...
518+
519+
# Build for different platforms
520+
GOOS=linux GOARCH=amd64 go build -o postgresql-archiver-linux-amd64
521+
GOOS=darwin GOARCH=arm64 go build -o postgresql-archiver-darwin-arm64
522+
GOOS=windows GOARCH=amd64 go build -o postgresql-archiver.exe
523+
```
524+
525+
### CI/CD
526+
527+
The project uses GitHub Actions for continuous integration:
528+
529+
- **Test Matrix**: Tests on Go 1.21.x and 1.22.x
530+
- **Platforms**: Linux, macOS, Windows
531+
- **Coverage**: Runs tests with coverage reporting
532+
- **Linting**: Ensures code quality with golangci-lint
533+
- **Binary Builds**: Creates binaries for multiple platforms
534+
444535
## 🤝 Contributing
445536

446537
Contributions are welcome! Please feel free to submit a Pull Request.
447538

539+
1. Fork the repository
540+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
541+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
542+
4. Push to the branch (`git push origin feature/amazing-feature`)
543+
5. Open a Pull Request
544+
448545
## 📄 License
449546

450547
MIT License - see LICENSE file for details

0 commit comments

Comments
 (0)