Skip to content

test: increase test coverage for go-getter downloader to 77.7%#1443

Merged
aknysh merged 3 commits intoupdate-go-getterfrom
go-getter-test-coverage
Sep 3, 2025
Merged

test: increase test coverage for go-getter downloader to 77.7%#1443
aknysh merged 3 commits intoupdate-go-getterfrom
go-getter-test-coverage

Conversation

@osterman
Copy link
Member

@osterman osterman commented Sep 3, 2025

Summary

  • Increased test coverage for the go-getter downloader package from 46.1% to 77.7%
  • Added comprehensive test suite for critical git operations that previously had 0% coverage
  • Applied golangci-lint recommendations and code formatting

Test Coverage Improvements

Before (46.1% total coverage):

  • GetCustom: 7.3%
  • checkout: 0%
  • clone: 0%
  • update: 0%
  • fetchSubmodules: 0%
  • findRemoteDefaultBranch: 0%
  • CustomGitGetter.Get: 0%

After (77.7% total coverage):

  • GetCustom: 89.1%
  • checkout: 100%
  • clone: 90.9%
  • update: 86.5%
  • fetchSubmodules: 100%
  • findRemoteDefaultBranch: 100%
  • CustomGitGetter.Get: 100%

Changes Made

  1. Added comprehensive test suite (pkg/downloader/get_git_test.go):

    • Tests for invalid port handling
    • SSH key authentication scenarios
    • Git version checking
    • Clone/update/checkout operations
    • Submodule fetching
    • Timeout handling
    • Integration tests
  2. Enhanced git_getter tests (pkg/downloader/git_getter_test.go):

    • Added tests for CustomGitGetter.Get() method
    • Symlink removal scenarios
    • Error propagation tests
  3. Code quality improvements:

    • Defined static errors in errors/errors.go to comply with golangci-lint err113 rule
    • Applied gofumpt formatting
    • Fixed error wrapping to use static errors

Test Execution

go test -coverprofile=coverage.out ./pkg/downloader/...
go tool cover -func=coverage.out | grep total
# total: (statements) 77.7%

🤖 Generated with Claude Code

- Add comprehensive tests for GetCustom() method covering various scenarios (89.1% coverage)
- Add tests for git operations: clone (90.9%), update (86.5%), checkout (100%), fetchSubmodules (100%)
- Add tests for findRemoteDefaultBranch() method (100% coverage)
- Add tests for CustomGitGetter.Get() method (100% coverage)
- Define static errors in errors/errors.go to comply with golangci-lint err113
- Format code with gofumpt
- Overall package coverage increased from 46.1% to 77.7%

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@osterman osterman requested a review from a team as a code owner September 3, 2025 01:53
@mergify mergify bot added stacked Stacked triage Needs triage labels Sep 3, 2025
@aknysh aknysh added no-release Do not create a new release (wait for additional code changes) and removed triage Needs triage labels Sep 3, 2025
@codecov
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.91%. Comparing base (cf7273e) to head (5fbaeec).
⚠️ Report is 1 commits behind head on update-go-getter.

Files with missing lines Patch % Lines
pkg/downloader/get_git.go 80.00% 2 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           update-go-getter    #1443      +/-   ##
====================================================
+ Coverage             55.60%   55.91%   +0.31%     
====================================================
  Files                   274      274              
  Lines                 28901    28902       +1     
====================================================
+ Hits                  16070    16161      +91     
+ Misses                11032    10945      -87     
+ Partials               1799     1796       -3     
Flag Coverage Δ
unittests 55.91% <80.00%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aknysh aknysh merged commit 3bdd0f6 into update-go-getter Sep 3, 2025
44 checks passed
@aknysh aknysh deleted the go-getter-test-coverage branch September 3, 2025 03:10
aknysh added a commit that referenced this pull request Sep 3, 2025
* updates

* updates

* updates

* updates

* updates

* updates

* [autofix.ci] apply automated fixes

* updates

* [autofix.ci] apply automated fixes

* updates

* updates

* updates

* updates

* test: increase test coverage for go-getter downloader to 77.7% (#1443)

* test: increase test coverage for go-getter downloader to 77.7%

- Add comprehensive tests for GetCustom() method covering various scenarios (89.1% coverage)
- Add tests for git operations: clone (90.9%), update (86.5%), checkout (100%), fetchSubmodules (100%)
- Add tests for findRemoteDefaultBranch() method (100% coverage)
- Add tests for CustomGitGetter.Get() method (100% coverage)
- Define static errors in errors/errors.go to comply with golangci-lint err113
- Format code with gofumpt
- Overall package coverage increased from 46.1% to 77.7%

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [autofix.ci] apply automated fixes

* updates

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: aknysh <andriy.knysh@gmail.com>

* fix: resolve golangci-lint issues in pkg/downloader (#1445)

- Replace deprecated io/ioutil with os.CreateTemp
- Add constants for magic numbers (base10, portBitSize, sshKeyFileMode)
- Add constants for repeated strings (gitCommand, originRemote, gitArgSeparator)
- Create gitOperationParams struct to reduce function arguments
- Fix invalid URL construction in tests
- Remove unused return values from test helper functions
- Fix potential index out of bounds issue
- Add #nosec comments for validated subprocess commands
- Apply gofumpt formatting

Reduces linting issues from 20 to 6 (remaining are complexity warnings)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>
Co-authored-by: Claude <noreply@anthropic.com>
osterman added a commit that referenced this pull request Sep 23, 2025
* updates

* updates

* updates

* updates

* updates

* updates

* [autofix.ci] apply automated fixes

* updates

* [autofix.ci] apply automated fixes

* updates

* updates

* updates

* updates

* test: increase test coverage for go-getter downloader to 77.7% (#1443)

* test: increase test coverage for go-getter downloader to 77.7%

- Add comprehensive tests for GetCustom() method covering various scenarios (89.1% coverage)
- Add tests for git operations: clone (90.9%), update (86.5%), checkout (100%), fetchSubmodules (100%)
- Add tests for findRemoteDefaultBranch() method (100% coverage)
- Add tests for CustomGitGetter.Get() method (100% coverage)
- Define static errors in errors/errors.go to comply with golangci-lint err113
- Format code with gofumpt
- Overall package coverage increased from 46.1% to 77.7%

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [autofix.ci] apply automated fixes

* updates

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: aknysh <andriy.knysh@gmail.com>

* fix: resolve golangci-lint issues in pkg/downloader (#1445)

- Replace deprecated io/ioutil with os.CreateTemp
- Add constants for magic numbers (base10, portBitSize, sshKeyFileMode)
- Add constants for repeated strings (gitCommand, originRemote, gitArgSeparator)
- Create gitOperationParams struct to reduce function arguments
- Fix invalid URL construction in tests
- Remove unused return values from test helper functions
- Fix potential index out of bounds issue
- Add #nosec comments for validated subprocess commands
- Apply gofumpt formatting

Reduces linting issues from 20 to 6 (remaining are complexity warnings)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <erik@cloudposse.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) stacked Stacked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants