fleet/tools/github-manage/pkg/ghapi
George Karr 6ebbef874b
adding sum of estimates and fixing workflow progress menu (#32694)
What’s in this PR

1) Smarter default sorting for issues (used by the TUI)

New ghapi.SortIssuesForDisplay helper that orders issues by:

Priority label (P0 → P1 → P2 → none)

Presence of customer-* / prospect-* labels

Type labels (story → bug → ~sub-task → others)

Issue number (descending)
This is applied before filtering so views start in a meaningful order. 
[GitHub](https://github.com/fleetdm/fleet/pull/32694/files)

Implementation lives in tools/github-manage/pkg/ghapi/sort.go.
Comprehensive tests cover all combinations, tie-breakers, and stability.
GitHub
+1

2) Estimates: show the sum for the current selection

The header now displays Σest sel=<sum> for the currently selected
issues, both in filtered and unfiltered views, making quick capacity
checks easier.
[GitHub](https://github.com/fleetdm/fleet/pull/32694/files)

3) Better progress UI for workflows

Task list is now windowed (last ~10 items) with auto-scroll to the
currently running or most recently finished task, plus “earlier/more
tasks” ellipses and a progress counter at the bottom. This keeps the
view focused during long runs.
[GitHub](https://github.com/fleetdm/fleet/pull/32694/files)

4) Project estimates fetch now includes total count

Switched from GetEstimatedTicketsForProject to
GetEstimatedTicketsForProjectWithTotal, so we can show totalAvailable
alongside rawFetched/limit.
[GitHub](https://github.com/fleetdm/fleet/pull/32694/files)

---------

Co-authored-by: Jordan Montgomery <elijah.jordan.montgomery@gmail.com>
2025-09-11 13:47:46 -05:00
..
cache.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
cli.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
cli_test.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
issues.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
issues_test.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
models.go gkarr gm updates (#32625) 2025-09-05 16:28:36 -05:00
models_test.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
projects.go gkarr gm updates (#32625) 2025-09-05 16:28:36 -05:00
projects_test.go gkarr gm updates (#32625) 2025-09-05 16:28:36 -05:00
README.md Github Manager (#31540) 2025-08-07 15:00:36 -05:00
relations.go gkarr gm updates (#32625) 2025-09-05 16:28:36 -05:00
sort.go adding sum of estimates and fixing workflow progress menu (#32694) 2025-09-11 13:47:46 -05:00
sort_test.go adding sum of estimates and fixing workflow progress menu (#32694) 2025-09-11 13:47:46 -05:00
suite_test.go gkarr gm updates (#32625) 2025-09-05 16:28:36 -05:00
TEST_SUMMARY.md Github Manager (#31540) 2025-08-07 15:00:36 -05:00
views.go adding sum of estimates and fixing workflow progress menu (#32694) 2025-09-11 13:47:46 -05:00
views_test.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
workflows.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00
workflows_test.go Github Manager (#31540) 2025-08-07 15:00:36 -05:00

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 functions
  • issues_test.go - Tests for GitHub issues management functions
  • models_test.go - Tests for data models and struct conversion functions
  • projects_test.go - Tests for GitHub Projects API functions
  • views_test.go - Tests for view management and display functions
  • workflows_test.go - Tests for bulk workflow operations
  • suite_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:

  1. Install and authenticate GitHub CLI
  2. Have access to the Fleet repository
  3. Run tests with appropriate environment setup

Mocking

For proper integration testing, consider implementing mocks for:

  • RunCommandAndReturnOutput function
  • 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