Skip to content

test(cmd/gf): add unit tests for geninit package#4640

Merged
gqcn merged 1 commit intogogf:masterfrom
lingcoder:test/geninit-unit-tests
Jan 21, 2026
Merged

test(cmd/gf): add unit tests for geninit package#4640
gqcn merged 1 commit intogogf:masterfrom
lingcoder:test/geninit-unit-tests

Conversation

@lingcoder
Copy link
Contributor

Summary

  • Add comprehensive unit tests for the geninit package which handles project initialization from templates
  • 17 new test cases covering core functionality

Test Coverage

Function Tests Description
ParseGitURL 7 Git URL parsing with various formats
IsSubdirRepo 3 Subdirectory detection
GetModuleNameFromGoMod 3 Module name extraction
ASTReplacer 2 Import path replacement
findGoFiles 2 Go file discovery

Test plan

  • All 17 tests pass locally
  • No modifications to existing code
  • New test file only: geninit_z_unit_test.go

Add comprehensive unit tests for the geninit package which handles
project initialization from templates. The tests cover:

- ParseGitURL: Git URL parsing with various formats (basic, https, subpath, tree/branch, version)
- IsSubdirRepo: Subdirectory detection for Go modules vs git subdirectories
- GetModuleNameFromGoMod: Module name extraction from go.mod files
- ASTReplacer: Import path replacement using Go AST
- findGoFiles: Recursive Go file discovery

17 new test cases added.
@gqcn gqcn merged commit 4f43b40 into gogf:master Jan 21, 2026
18 checks passed
@lingcoder lingcoder deleted the test/geninit-unit-tests branch February 28, 2026 00:33
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.

2 participants