Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test Suite

on:
push:
pull_request:

permissions:
contents: read
checks: write
pull-requests: write

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: true

- name: Download dependencies
run: go mod download

- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest

- name: Run tests with coverage
run: |
go test ./... -v -race -coverprofile=coverage.out -covermode=atomic 2>&1 | tee test-output.txt || true
cat test-output.txt | go-junit-report -set-exit-code > test-results.xml

- name: Generate coverage report
run: |
echo "## Test Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
go tool cover -func=coverage.out | tail -n 1 | awk '{print "**Total Coverage: " $3 "**"}' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Coverage by Package" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Package | Coverage |" >> $GITHUB_STEP_SUMMARY
echo "|---------|----------|" >> $GITHUB_STEP_SUMMARY
go tool cover -func=coverage.out | grep -v "total:" | awk '{print "| " $1 " | " $3 " |"}' | sort -u >> $GITHUB_STEP_SUMMARY

- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: Go Test Results
path: test-results.xml
reporter: 'java-junit'
fail-on-error: true
fail-on-empty: true

- name: Upload coverage to GitHub
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.out

- name: Check test results
run: |
if grep -q 'failures="[1-9]' test-results.xml || grep -q 'errors="[1-9]' test-results.xml; then
echo "Some tests failed"
exit 1
else
echo "All tests passed"
fi
31 changes: 29 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,25 @@ mock_mode: true # Enable mock mode
# Quick start with mock data (no Fastmail account required)
go run main.go -config config-mock.yaml.example

# Run all tests (when implemented)
# Run all tests
go test ./...

# Run tests with verbose output
go test ./... -v

# Run with race detection
go test -race ./...

# Run tests with coverage
go test ./... -cover

# Generate coverage report
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out

# Run benchmarks
go test ./... -bench=.

# Lint the code (requires golangci-lint)
golangci-lint run
```
Expand Down Expand Up @@ -363,7 +376,21 @@ log.SetFlags(log.LstdFlags | log.Lshortfile)
3. **Interface Design:** Clean separation of concerns
4. **Memory Management:** Efficient string operations and minimal allocations
5. **Concurrency Safety:** Thread-safe operations where needed
6. **Testing Ready:** Structured for unit test implementation
6. **Comprehensive Testing:** Full unit test coverage with table-driven tests

### Test Coverage
The project includes comprehensive unit tests for all packages:
- **Config Package:** Configuration loading, validation, and error handling
- **JMAP Package:** Data parsing, mock client functionality, and helper functions
- **Similarity Package:** Fuzzy matching algorithms, Levenshtein distance, email similarity
- **Server Package:** HTTP handlers, API endpoints, and request/response handling

Tests follow Go best practices:
- Table-driven test design for multiple scenarios
- Clear test naming and organization
- Use of test helpers and fixtures
- Mock clients for external dependencies
- Benchmark tests for performance-critical functions

### Code Style
- **Naming:** Clear, descriptive variable and function names
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Mailbox Zero - Email Cleanup Helper

[![Test Suite](https://github.com/taskinen/mailboxzero/actions/workflows/test.yml/badge.svg)](https://github.com/taskinen/mailboxzero/actions/workflows/test.yml)
[![Go Version](https://img.shields.io/badge/Go-1.21+-00ADD8?style=flat&logo=go)](https://go.dev/)
[![Go Report Card](https://goreportcard.com/badge/github.com/taskinen/mailboxzero)](https://goreportcard.com/report/github.com/taskinen/mailboxzero)
[![Made with Go](https://img.shields.io/badge/Made%20with-Go-1f425f.svg)](https://go.dev/)

A Go-based web application that helps you clean up your Fastmail inbox by finding and archiving similar emails using JMAP protocol.

<img width="1457" height="1169" alt="SCR-20250827-psxl" src="https://github.com/user-attachments/assets/2f1fe630-5ba7-4c8a-a610-6f32388654b5" />
Expand Down Expand Up @@ -169,6 +174,25 @@ mailboxzero/
└── static/ # CSS and JavaScript files
```

### Running Tests

The project includes comprehensive unit tests for all packages:

```bash
# Run all tests
go test ./...

# Run tests with verbose output
go test ./... -v

# Run tests with coverage
go test ./... -cover

# Generate coverage report
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out
```

## License

This project is provided as-is for educational and personal use.
Loading