Comprehensive TDD test coverage for the Beeper CLI tool.
- ✅ JSON formatting for chats and messages
- ✅ Plain text formatting
- ✅ Markdown formatting
- ✅ Empty list handling
- ✅ Invalid format fallback
- ✅ Chat name edge cases
- ✅ Timestamp formatting
- ✅ Long messages
- ✅ Special characters escaping
Run:
go test ./internal/output -v- ✅ Load/save configuration from file
- ✅ Default configuration values
- ✅ Configuration validation
- ✅ Environment variable override
- ✅ Configuration merging
- ✅ Partial configuration updates
- ✅ File permissions
- ✅ Invalid YAML handling
Run:
go test ./internal/config -vTests real HTTP communication with Beeper Desktop API.
Prerequisites:
- Beeper Desktop running
BEEPER_API_URLset (default: http://[::1]:23373)BEEPER_TOKENset (Bearer token from Beeper settings)
Tests:
- ListChats - fetch all conversations
- GetChat - fetch specific chat details
- ListMessages - fetch messages from a chat
- SendMessage - send a message (requires
BEEPER_TEST_CHAT_ID) - SearchMessages - search across all messages
- Ping - health check
- Error handling for invalid URLs
Run:
export BEEPER_API_URL="http://[::1]:23373"
export BEEPER_TOKEN="your-token-here"
export BEEPER_TEST_CHAT_ID="safe-test-chat-id" # Optional, for send tests
go test ./internal/api -vSkip behavior:
- Tests automatically skip if
BEEPER_API_URLorBEEPER_TOKENnot set - Send tests skip if
BEEPER_TEST_CHAT_IDnot set
Tests CLI command execution with real API.
Prerequisites: Same as API tests above
Tests:
chats list- JSON, text, markdown formatschats get- specific chat retrievalmessages list- with limit parametersend- message sending + error casessearch- keyword search with limitsdiscover- API discoveryconfig- show/set/get/validate
Run:
go test ./cmd -vFull workflow tests using the compiled binary.
Prerequisites:
- Built binary at
./beeper - Live Beeper Desktop API
- Environment variables set
Tests:
- Complete workflow (discover → list → get → messages → send → search)
- All output formats (JSON/text/markdown)
- Error handling scenarios
- Configuration management workflow
- Unix pipeline compatibility (jq, grep)
Run:
# Build first
./build.sh
# Run integration tests
go test -tags=integration -v- Open Beeper Desktop
- Go to Settings → Advanced → API
- Enable API access
- Copy the Bearer token
export BEEPER_API_URL="http://[::1]:23373"
export BEEPER_TOKEN="your-bearer-token-here"
# Optional: for safe send testing
export BEEPER_TEST_CHAT_ID="your-test-chat-id"./beeper chats list --output json | jq -r '.[0].id'go test ./internal/output ./internal/config -v# Ensure Beeper Desktop is running and env vars are set
go test ./internal/api ./cmd -v# Unit + Integration
go test ./... -v
# Including E2E integration tests
./build.sh && go test -tags=integration ./... -vgo test ./... -coverprofile=coverage.out
go tool cover -html=coverage.outbeeper-api-cli/
├── internal/
│ ├── api/
│ │ ├── client.go
│ │ └── client_test.go # Real API tests
│ ├── config/
│ │ ├── config.go
│ │ └── config_test.go # Config management tests
│ └── output/
│ ├── formatter.go
│ └── formatter_test.go # Formatter unit tests
├── cmd/
│ ├── chats.go
│ ├── chats_test.go # Command tests
│ ├── messages_test.go
│ ├── send_test.go
│ ├── search_test.go
│ ├── discover_test.go
│ └── config_test.go
└── integration_test.go # E2E workflow tests
name: Tests
on: [push, pull_request]
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run unit tests
run: go test ./internal/output ./internal/config -v
integration-tests:
runs-on: ubuntu-latest
services:
beeper:
# Mock Beeper API service (if available)
# Or skip integration tests in CI
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run integration tests
run: |
export BEEPER_API_URL="${{ secrets.BEEPER_API_URL }}"
export BEEPER_TOKEN="${{ secrets.BEEPER_TOKEN }}"
go test ./internal/api ./cmd -v
continue-on-error: true # Allow failure if API not available- TDD Approach: Tests written first, following Test-Driven Development
- Real API: Integration tests use actual Beeper Desktop API (no mocks)
- Graceful Skipping: Tests skip automatically if environment not configured
- Isolated Unit Tests: Formatter and config tests don't require external services
- Table-Driven: Common patterns use table-driven tests
- Clean Assertions: Using testify/assert for readable test code
- Ensure Beeper Desktop is running
- Verify API is enabled in Beeper settings
- Check
BEEPER_API_URLmatches your Beeper API port
- Set
BEEPER_API_URLandBEEPER_TOKENenvironment variables - Tests requiring API will skip if these are not set
- Set
BEEPER_TEST_CHAT_IDto a safe test chat - Ensure you have permission to send to that chat
- Increase coverage to >80% (current: comprehensive for core modules)
- Add benchmark tests for performance
- Create mock Beeper API server for CI/CD
- Add mutation testing
- Property-based testing for complex scenarios