Skip to content

Significant Test Coverage Improvement#4

Open
tryonlinux wants to merge 1 commit into
mainfrom
test-coverage-improvement-5151993689899089310
Open

Significant Test Coverage Improvement#4
tryonlinux wants to merge 1 commit into
mainfrom
test-coverage-improvement-5151993689899089310

Conversation

@tryonlinux

Copy link
Copy Markdown
Owner

Achieved approximately 91% test coverage across the application's internal logic and CLI commands. This was accomplished by adding new unit tests for validation, configuration, and database modules, as well as comprehensive integration tests for the CLI commands. The tests use environment isolation (temporary home directories) and input simulation (pipes) to thoroughly exercise the application's features, including first-time setup and interactive prompts.


PR created automatically by Jules for task 5151993689899089310 started by @tryonlinux

- Added `tests/validation_test.go` with 100% coverage for the validation package.
- Added `tests/config_test.go` to test database path configuration.
- Added `tests/database_test.go` to test database initialization and schema creation.
- Added `tests/cmd_test.go` with comprehensive integration tests for all CLI commands.
- Updated `tests/models_test.go` to cover setup flows, reset logic, and error paths.
- Updated `tests/display_test.go` to cover edge cases in table and graph rendering.
- Fixed minor linting issues in `internal/models/settings.go`.

Overall coverage for `internal/` and `cmd/` packages increased to approximately 91.2%. Remaining uncovered code consists mainly of low-level I/O and database driver error paths.

Co-authored-by: tryonlinux <13523516+tryonlinux@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown

✅ Test Results: PASSED

Test Output
=== RUN   TestCalculateBMI_MetricUnits
--- PASS: TestCalculateBMI_MetricUnits (0.00s)
=== RUN   TestCalculateBMI_ImperialUnits
--- PASS: TestCalculateBMI_ImperialUnits (0.00s)
=== RUN   TestCalculateBMI_MixedUnits_KgInches
--- PASS: TestCalculateBMI_MixedUnits_KgInches (0.00s)
=== RUN   TestCalculateBMI_MixedUnits_LbsCm
--- PASS: TestCalculateBMI_MixedUnits_LbsCm (0.00s)
=== RUN   TestCalculateBMI_Underweight
--- PASS: TestCalculateBMI_Underweight (0.00s)
=== RUN   TestCalculateBMI_Overweight
--- PASS: TestCalculateBMI_Overweight (0.00s)
=== RUN   TestCLICommands
Error: value must be a positive number
Error: value must be a positive number
Error: weight must be between 1 and 1000
Error: date must be in YYYY-MM-DD format and be a valid date
                                     
 ████████╗██╗  ██╗██╗ ██████╗ ██████╗
 ╚══██╔══╝██║  ██║██║██╔════╝██╔════╝
    ██║   ███████║██║██║     ██║     
    ██║   ██╔══██║██║██║     ██║     
    ██║   ██║  ██║██║╚██████╗╚██████╗
    ╚═╝   ╚═╝  ╚═╝╚═╝ ╚═════╝ ╚═════╝
    Weight Tracker                   
                                     
Latest: 160.50 lbs | BMI: 23.0 | Avg: 159.25 lbs | Gained 2.50 lbs
                                                                  
Min: 158.00 lbs | Max: 160.50 lbs | Entries: 2


                   Goal Weight: 150.00 lbs (10.5 lbs to lose)                   

┌──┬──────────┬──────────┬────┐  ┌──────────────────────────────────────────────────────┐
│ID│Date      │Weight    │BMI │  │ 161.6 lbs ┤                                          │
├──┼──────────┼──────────┼────┤  │         │                                            │
│1 │2026-04-04│160.50 lbs│23.0│  │         │                                            │
│2 │2024-01-01│158.00 lbs│22.7│  │         │ ·                                          │
└──┴──────────┴──────────┴────┘  │         │ ∙                                          │
                                 │         │∙                                           │
                                 │         │∙                                           │
                                 │         │·                                           │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │ Goal: 150.0┤──────────────────────────────────────── │
                                 │         │                                            │
                                 │ 148.9 lbs ┤────────────────────────────────────────  │
                                 │         2024-01-01                    2026-04-04     │
                                 │                                                      │
                                 └──────────────────────────────────────────────────────┘
Error: Number must be positive
Error: Number must be positive
                                     
 ████████╗██╗  ██╗██╗ ██████╗ ██████╗
 ╚══██╔══╝██║  ██║██║██╔════╝██╔════╝
    ██║   ███████║██║██║     ██║     
    ██║   ██╔══██║██║██║     ██║     
    ██║   ██║  ██║██║╚██████╗╚██████╗
    ╚═╝   ╚═╝  ╚═╝╚═╝ ╚═════╝ ╚═════╝
    Weight Tracker                   
                                     
Latest: 160.50 lbs | BMI: 23.0 | Avg: 159.25 lbs | Gained 2.50 lbs
                                                                  
Min: 158.00 lbs | Max: 160.50 lbs | Entries: 2


                   Goal Weight: 150.00 lbs (10.5 lbs to lose)                   

┌──┬──────────┬──────────┬────┐  ┌──────────────────────────────────────────────────────┐
│ID│Date      │Weight    │BMI │  │ 161.6 lbs ┤                                          │
├──┼──────────┼──────────┼────┤  │         │                                            │
│1 │2026-04-04│160.50 lbs│23.0│  │         │                                            │
│2 │2024-01-01│158.00 lbs│22.7│  │         │ ·                                          │
└──┴──────────┴──────────┴────┘  │         │ ∙                                          │
                                 │         │∙                                           │
                                 │         │∙                                           │
                                 │         │·                                           │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │ Goal: 150.0┤──────────────────────────────────────── │
                                 │         │                                            │
                                 │ 148.9 lbs ┤────────────────────────────────────────  │
                                 │         2024-01-01                    2026-04-04     │
                                 │                                                      │
                                 └──────────────────────────────────────────────────────┘
Error: Argument must be a positive number or a date in YYYY-MM-DD format
Error: value must be a positive number
Updated weight entry 1 to 159.50 lbs (BMI: 22.9)
                                     
 ████████╗██╗  ██╗██╗ ██████╗ ██████╗
 ╚══██╔══╝██║  ██║██║██╔════╝██╔════╝
    ██║   ███████║██║██║     ██║     
    ██║   ██╔══██║██║██║     ██║     
    ██║   ██║  ██║██║╚██████╗╚██████╗
    ╚═╝   ╚═╝  ╚═╝╚═╝ ╚═════╝ ╚═════╝
    Weight Tracker                   
                                     
Latest: 159.50 lbs | BMI: 22.9 | Avg: 158.75 lbs | Gained 1.50 lbs
                                                                  
Min: 158.00 lbs | Max: 159.50 lbs | Entries: 2


                   Goal Weight: 145.00 lbs (14.5 lbs to lose)                   

┌──┬──────────┬──────────┬────┐  ┌──────────────────────────────────────────────────────┐
│ID│Date      │Weight    │BMI │  │ 160.9 lbs ┤                                          │
├──┼──────────┼──────────┼────┤  │         │                                            │
│1 │2026-04-04│159.50 lbs│22.9│  │         │                                            │
│2 │2024-01-01│158.00 lbs│22.7│  │         │ ·                                          │
└──┴──────────┴──────────┴────┘  │         │∙                                           │
                                 │         │·                                           │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │ Goal: 145.0┤──────────────────────────────────────── │
                                 │         │                                            │
                                 │ 143.6 lbs ┤────────────────────────────────────────  │
                                 │         2024-01-01                    2026-04-04     │
                                 │                                                      │
                                 └──────────────────────────────────────────────────────┘
Error: Weight ID must be a positive number
Error: value must be a positive number
Deleted weight entry with ID 2
                                     
 ████████╗██╗  ██╗██╗ ██████╗ ██████╗
 ╚══██╔══╝██║  ██║██║██╔════╝██╔════╝
    ██║   ███████║██║██║     ██║     
    ██║   ██╔══██║██║██║     ██║     
    ██║   ██║  ██║██║╚██████╗╚██████╗
    ╚═╝   ╚═╝  ╚═╝╚═╝ ╚═════╝ ╚═════╝
    Weight Tracker                   
                                     
Latest: 159.50 lbs | BMI: 22.9 | Avg: 159.50 lbs | No change
                                                            
Min: 159.50 lbs | Max: 159.50 lbs | Entries: 1


                   Goal Weight: 145.00 lbs (14.5 lbs to lose)                   

┌──┬──────────┬──────────┬────┐  ┌──────────────────────────────────────────────────────┐
│ID│Date      │Weight    │BMI │  │ 160.9 lbs ┤                                          │
├──┼──────────┼──────────┼────┤  │         │                                            │
│1 │2026-04-04│159.50 lbs│22.9│  │         │                                            │
└──┴──────────┴──────────┴────┘  │         │·                                           │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │         │                                            │
                                 │ Goal: 145.0┤──────────────────────────────────────── │
                                 │         │                                            │
                                 │ 143.6 lbs ┤────────────────────────────────────────  │
                                 │         2026-04-04                    2026-04-04     │
                                 │                                                      │
                                 └──────────────────────────────────────────────────────┘
Error: Weight ID must be a positive number
WARNING: This will delete ALL weight entries and settings.
Are you sure you want to continue? (yes/no): Reset cancelled.
--- PASS: TestCLICommands (0.05s)
=== RUN   TestGetDatabasePath
--- PASS: TestGetDatabasePath (0.00s)
=== RUN   TestOpenError
--- PASS: TestOpenError (0.00s)
=== RUN   TestInitializeSchema
--- PASS: TestInitializeSchema (0.00s)
=== RUN   TestFormatWeight
--- PASS: TestFormatWeight (0.00s)
=== RUN   TestFormatBMI
--- PASS: TestFormatBMI (0.00s)
=== RUN   TestFormatDate
--- PASS: TestFormatDate (0.00s)
=== RUN   TestRenderWeightsTableDelta
=== RUN   TestRenderWeightsTableDelta/weight_loss_shows_'Lost'
=== RUN   TestRenderWeightsTableDelta/weight_gain_shows_'Gained'
=== RUN   TestRenderWeightsTableDelta/no_change_shows_'No_change'
=== RUN   TestRenderWeightsTableDelta/metric_units_show_correctly
--- PASS: TestRenderWeightsTableDelta (0.00s)
    --- PASS: TestRenderWeightsTableDelta/weight_loss_shows_'Lost' (0.00s)
    --- PASS: TestRenderWeightsTableDelta/weight_gain_shows_'Gained' (0.00s)
    --- PASS: TestRenderWeightsTableDelta/no_change_shows_'No_change' (0.00s)
    --- PASS: TestRenderWeightsTableDelta/metric_units_show_correctly (0.00s)
=== RUN   TestGoalDifferenceCalculation
=== RUN   TestGoalDifferenceCalculation/Need_to_lose_weight
=== RUN   TestGoalDifferenceCalculation/Need_to_gain_weight
=== RUN   TestGoalDifferenceCalculation/At_goal_weight
=== RUN   TestGoalDifferenceCalculation/Small_amount_to_lose
=== RUN   TestGoalDifferenceCalculation/Large_amount_to_gain
--- PASS: TestGoalDifferenceCalculation (0.00s)
    --- PASS: TestGoalDifferenceCalculation/Need_to_lose_weight (0.00s)
    --- PASS: TestGoalDifferenceCalculation/Need_to_gain_weight (0.00s)
    --- PASS: TestGoalDifferenceCalculation/At_goal_weight (0.00s)
    --- PASS: TestGoalDifferenceCalculation/Small_amount_to_lose (0.00s)
    --- PASS: TestGoalDifferenceCalculation/Large_amount_to_gain (0.00s)
=== RUN   TestGoalWeightWithWeightEntries
--- PASS: TestGoalWeightWithWeightEntries (0.02s)
=== RUN   TestGoalWeightEdgeCases
=== RUN   TestGoalWeightEdgeCases/Normal_goal
=== RUN   TestGoalWeightEdgeCases/Zero_goal
=== RUN   TestGoalWeightEdgeCases/Large_goal
=== RUN   TestGoalWeightEdgeCases/Small_goal
=== RUN   TestGoalWeightEdgeCases/Decimal_goal
--- PASS: TestGoalWeightEdgeCases (0.03s)
    --- PASS: TestGoalWeightEdgeCases/Normal_goal (0.01s)
    --- PASS: TestGoalWeightEdgeCases/Zero_goal (0.01s)
    --- PASS: TestGoalWeightEdgeCases/Large_goal (0.01s)
    --- PASS: TestGoalWeightEdgeCases/Small_goal (0.01s)
    --- PASS: TestGoalWeightEdgeCases/Decimal_goal (0.01s)
=== RUN   TestAddAndGetWeights
--- PASS: TestAddAndGetWeights (0.01s)
=== RUN   TestDeleteWeight
--- PASS: TestDeleteWeight (0.01s)
=== RUN   TestModifyWeight
--- PASS: TestModifyWeight (0.01s)
=== RUN   TestGetWeightsBetweenDates
--- PASS: TestGetWeightsBetweenDates (0.01s)
=== RUN   TestGoalWeightSetting
--- PASS: TestGoalWeightSetting (0.01s)
=== RUN   TestUpdateGoalWeight
--- PASS: TestUpdateGoalWeight (0.01s)
=== RUN   TestGoalWeightDifferentUnits
=== RUN   TestGoalWeightDifferentUnits/Imperial
=== RUN   TestGoalWeightDifferentUnits/Metric
=== RUN   TestGoalWeightDifferentUnits/Mixed_LbsCm
=== RUN   TestGoalWeightDifferentUnits/Mixed_KgIn
--- PASS: TestGoalWeightDifferentUnits (0.03s)
    --- PASS: TestGoalWeightDifferentUnits/Imperial (0.01s)
    --- PASS: TestGoalWeightDifferentUnits/Metric (0.01s)
    --- PASS: TestGoalWeightDifferentUnits/Mixed_LbsCm (0.01s)
    --- PASS: TestGoalWeightDifferentUnits/Mixed_KgIn (0.01s)
=== RUN   TestResetSettings
--- PASS: TestResetSettings (0.01s)
=== RUN   TestGetTodayDate
--- PASS: TestGetTodayDate (0.00s)
=== RUN   TestModelsErrorPaths
--- PASS: TestModelsErrorPaths (0.01s)
=== RUN   TestSetupSettings

=== First Time Setup ===
Please configure your preferences.
Weight unit (lbs/kg): Invalid input. Please enter 'lbs' or 'kg'.
Weight unit (lbs/kg): Height unit (in/cm): Your height (cm): Your goal weight (lbs): 
Settings saved successfully!

=== First Time Setup ===
Please configure your preferences.
Weight unit (lbs/kg): Height unit (in/cm): Your height (in): Invalid input. Please enter a positive number.
Your height (in): Invalid input. Please enter a positive number.
Your height (in): Your goal weight (kg): Invalid input. Please enter a positive number.
Your goal weight (kg): Invalid input. Please enter a positive number.
Your goal weight (kg): 
Settings saved successfully!
--- PASS: TestSetupSettings (0.01s)
=== RUN   TestValidateDate
=== RUN   TestValidateDate/valid_date
=== RUN   TestValidateDate/empty_date
=== RUN   TestValidateDate/invalid_format
=== RUN   TestValidateDate/invalid_date
=== RUN   TestValidateDate/invalid_day
=== RUN   TestValidateDate/not_a_date
--- PASS: TestValidateDate (0.00s)
    --- PASS: TestValidateDate/valid_date (0.00s)
    --- PASS: TestValidateDate/empty_date (0.00s)
    --- PASS: TestValidateDate/invalid_format (0.00s)
    --- PASS: TestValidateDate/invalid_date (0.00s)
    --- PASS: TestValidateDate/invalid_day (0.00s)
    --- PASS: TestValidateDate/not_a_date (0.00s)
=== RUN   TestValidateWeight
=== RUN   TestValidateWeight/valid_weight
=== RUN   TestValidateWeight/min_weight
=== RUN   TestValidateWeight/max_weight
=== RUN   TestValidateWeight/zero_weight
=== RUN   TestValidateWeight/negative_weight
=== RUN   TestValidateWeight/too_low_weight
=== RUN   TestValidateWeight/too_high_weight
--- PASS: TestValidateWeight (0.00s)
    --- PASS: TestValidateWeight/valid_weight (0.00s)
    --- PASS: TestValidateWeight/min_weight (0.00s)
    --- PASS: TestValidateWeight/max_weight (0.00s)
    --- PASS: TestValidateWeight/zero_weight (0.00s)
    --- PASS: TestValidateWeight/negative_weight (0.00s)
    --- PASS: TestValidateWeight/too_low_weight (0.00s)
    --- PASS: TestValidateWeight/too_high_weight (0.00s)
=== RUN   TestValidateBMI
=== RUN   TestValidateBMI/valid_BMI
=== RUN   TestValidateBMI/min_BMI
=== RUN   TestValidateBMI/max_BMI
=== RUN   TestValidateBMI/too_low_BMI
=== RUN   TestValidateBMI/too_high_BMI
--- PASS: TestValidateBMI (0.00s)
    --- PASS: TestValidateBMI/valid_BMI (0.00s)
    --- PASS: TestValidateBMI/min_BMI (0.00s)
    --- PASS: TestValidateBMI/max_BMI (0.00s)
    --- PASS: TestValidateBMI/too_low_BMI (0.00s)
    --- PASS: TestValidateBMI/too_high_BMI (0.00s)
=== RUN   TestValidateHeight
=== RUN   TestValidateHeight/valid_cm
=== RUN   TestValidateHeight/min_cm
=== RUN   TestValidateHeight/max_cm
=== RUN   TestValidateHeight/too_low_cm
=== RUN   TestValidateHeight/too_high_cm
=== RUN   TestValidateHeight/valid_in
=== RUN   TestValidateHeight/min_in
=== RUN   TestValidateHeight/max_in
=== RUN   TestValidateHeight/too_low_in
=== RUN   TestValidateHeight/too_high_in
=== RUN   TestValidateHeight/zero_height
=== RUN   TestValidateHeight/negative_height
=== RUN   TestValidateHeight/unknown_unit
--- PASS: TestValidateHeight (0.00s)
    --- PASS: TestValidateHeight/valid_cm (0.00s)
    --- PASS: TestValidateHeight/min_cm (0.00s)
    --- PASS: TestValidateHeight/max_cm (0.00s)
    --- PASS: TestValidateHeight/too_low_cm (0.00s)
    --- PASS: TestValidateHeight/too_high_cm (0.00s)
    --- PASS: TestValidateHeight/valid_in (0.00s)
    --- PASS: TestValidateHeight/min_in (0.00s)
    --- PASS: TestValidateHeight/max_in (0.00s)
    --- PASS: TestValidateHeight/too_low_in (0.00s)
    --- PASS: TestValidateHeight/too_high_in (0.00s)
    --- PASS: TestValidateHeight/zero_height (0.00s)
    --- PASS: TestValidateHeight/negative_height (0.00s)
    --- PASS: TestValidateHeight/unknown_unit (0.00s)
=== RUN   TestParsePositiveFloat
=== RUN   TestParsePositiveFloat/valid_float
=== RUN   TestParsePositiveFloat/valid_float_with_spaces
=== RUN   TestParsePositiveFloat/empty_string
=== RUN   TestParsePositiveFloat/just_spaces
=== RUN   TestParsePositiveFloat/not_a_number
=== RUN   TestParsePositiveFloat/zero
=== RUN   TestParsePositiveFloat/negative
--- PASS: TestParsePositiveFloat (0.00s)
    --- PASS: TestParsePositiveFloat/valid_float (0.00s)
    --- PASS: TestParsePositiveFloat/valid_float_with_spaces (0.00s)
    --- PASS: TestParsePositiveFloat/empty_string (0.00s)
    --- PASS: TestParsePositiveFloat/just_spaces (0.00s)
    --- PASS: TestParsePositiveFloat/not_a_number (0.00s)
    --- PASS: TestParsePositiveFloat/zero (0.00s)
    --- PASS: TestParsePositiveFloat/negative (0.00s)
=== RUN   TestParseAndValidateWeight
=== RUN   TestParseAndValidateWeight/valid_weight
=== RUN   TestParseAndValidateWeight/invalid_format
=== RUN   TestParseAndValidateWeight/out_of_range_low
=== RUN   TestParseAndValidateWeight/out_of_range_high
--- PASS: TestParseAndValidateWeight (0.00s)
    --- PASS: TestParseAndValidateWeight/valid_weight (0.00s)
    --- PASS: TestParseAndValidateWeight/invalid_format (0.00s)
    --- PASS: TestParseAndValidateWeight/out_of_range_low (0.00s)
    --- PASS: TestParseAndValidateWeight/out_of_range_high (0.00s)
PASS
ok  	github.com/tryonlinux/thicc/tests	0.222s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant