mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
This absolutely slams GitHub rate limits, but one API request per page of issues plus one API request per issue is the only sure way to get this data, so it is what it is. May need to add a "pick up where you left off" feature but this is at least a starting point. |
||
|---|---|---|
| .. | ||
| cache.go | ||
| cli.go | ||
| cli_test.go | ||
| estimates.go | ||
| issues.go | ||
| issues_test.go | ||
| milestone.go | ||
| models.go | ||
| models_test.go | ||
| projects.go | ||
| projects_test.go | ||
| README.md | ||
| relations.go | ||
| sort.go | ||
| sort_test.go | ||
| suite_test.go | ||
| TEST_SUMMARY.md | ||
| user.go | ||
| views.go | ||
| views_test.go | ||
| workflows.go | ||
| workflows_test.go | ||
GitHub Manage - ghapi Package Tests
This directory contains comprehensive tests for all functions in the ghapi package.
Test Files
cli_test.go- Tests for command line interface functionsissues_test.go- Tests for GitHub issues management functionsmodels_test.go- Tests for data models and struct conversion functionsprojects_test.go- Tests for GitHub Projects API functionsviews_test.go- Tests for view management and display functionsworkflows_test.go- Tests for bulk workflow operationssuite_test.go- Comprehensive test suite runner and benchmarks
Running Tests
Run All Tests
cd tools/github-manage
go test ./pkg/ghapi -v
Run Specific Test Files
go test ./pkg/ghapi -run TestCLI -v
go test ./pkg/ghapi -run TestIssues -v
go test ./pkg/ghapi -run TestModels -v
go test ./pkg/ghapi -run TestProjects -v
go test ./pkg/ghapi -run TestViews -v
go test ./pkg/ghapi -run TestWorkflows -v
Run Test Suite
go test ./pkg/ghapi -run TestSuite -v
Run Benchmarks
go test ./pkg/ghapi -bench=. -v
Run Tests with Coverage
go test ./pkg/ghapi -cover -v
go test ./pkg/ghapi -coverprofile=coverage.out
go tool cover -html=coverage.out
Test Categories
Unit Tests
- CLI Functions: Test command execution and output parsing
- JSON Parsing: Test parsing of GitHub API responses
- Data Models: Test struct marshaling/unmarshaling and conversions
- Project Management: Test project field lookups and caching
- View Management: Test view creation and filtering
- Workflow Operations: Test bulk operations (currently stubs)
Integration Tests
Some tests are skipped in the unit test suite because they require:
- GitHub CLI (
gh) to be installed and authenticated - Access to actual GitHub repositories and projects
- Network connectivity
To run integration tests, you need to:
- Install and authenticate GitHub CLI
- Have access to the Fleet repository
- Run tests with appropriate environment setup
Mocking
For proper integration testing, consider implementing mocks for:
RunCommandAndReturnOutputfunction- GitHub CLI commands
- External API calls
Test Coverage
The tests cover:
- ✅ Basic function signatures and return types
- ✅ JSON parsing and error handling
- ✅ Data structure validation
- ✅ Struct conversions and transformations
- ✅ Caching mechanisms
- ✅ Error conditions and edge cases
- ⚠️ GitHub CLI interactions (mocked/skipped)
- ⚠️ External API calls (mocked/skipped)
Notes
- Some tests are skipped on Windows due to bash command dependencies
- GitHub CLI-dependent tests are skipped without proper setup
- Stub functions (like
BulkSprintKickoff) only test basic structure - Consider implementing dependency injection for better testability