Add spec for MissingBinaries diagnostic
Overview
This issue addresses the need to add test coverage for the MissingBinaries diagnostic class. Currently, the lib/gdk/diagnostic/missing_binaries.rb diagnostic lacks comprehensive test coverage, which was identified during code review in merge request !4288 (merged).
The MissingBinaries diagnostic checks for the presence of required binary files (gitaly, gitlab-shell, workhorse, etc.) and provides helpful setup instructions when binaries are missing.
Implementation plan
1. Create the test file
Create a new spec file at spec/lib/gdk/diagnostic/missing_binaries_spec.rb following the existing pattern from spec/lib/gdk/diagnostic/loopback_spec.rb.
2. Test structure
The spec should include tests for:
Basic functionality:
-
#success?method returnstruewhen all required binaries exist -
#success?method returnsfalsewhen binaries are missing -
#detailmethod returnsnilwhen all binaries are present -
#detailmethod returns helpful instructions when binaries are missing
Configuration handling:
- Test behavior when OpenBao is enabled/disabled (affects required_binaries list)
3. Key testing patterns to follow
Mocking file system:
# Mock File.exist? and File.executable? for different scenarios
allow(File).to receive(:exist?).and_return(false)
allow(File).to receive(:executable?).and_return(false)
Mocking configuration:
# Use stub_gdk_yaml helper for configuration
stub_gdk_yaml <<~YAML
openbao:
enabled: true
YAML
Mocking PackageConfig:
# Mock the package configuration
allow(GDK::PackageConfig).to receive(:project).and_return({
download_paths: ['/path/to/binary']
})
4. Test scenarios to cover
- All binaries present - success case
- Some binaries missing - failure case with specific missing binaries
- Workhorse special handling - test the glob pattern matching
- OpenBao enabled/disabled - test conditional binary requirements
- GraphQL schema handling - test the special case that always passes
- Detail message formatting - verify the instructional message content
Note
As first iteration, testing at least one success and one failure case would suffice.
5. Reference files
-
Example spec:
spec/lib/gdk/diagnostic/loopback_spec.rb -
Implementation:
lib/gdk/diagnostic/missing_binaries.rb -
Base class:
lib/gdk/diagnostic/base.rb -
Package config:
lib/gdk/package_config.rb
The test should use RSpec best practices including descriptive context blocks, proper mocking, and clear expectations that verify both the success/failure states and the quality of error messages provided to users.