Skip to content

Conversation

@yukinagae
Copy link
Owner

This commit introduces new tests for the internal/paramify package, significantly increasing test coverage.

New test suites were added for:

  • ParsePackage: Verifies package loading, including handling of non-existent directories, directories with no Go files, and files with syntax errors.
  • ValuesOfType: Ensures correct extraction of required and optional fields from structs, covering a wide variety of field types (primitives, pointers, structs, arrays, maps, interfaces, any) and omitempty tags.

Enhancements were made to existing tests for:

  • isPointer: Added cases for arrays of pointers and maps with pointer values.
  • isInterface: Added cases for direct interface types and clarified behavior for aliases.
  • isOmitEmpty: Added cases for tags with multiple options and unrelated tags.

During the process of adding these tests, the following improvements were also made to the source code:

  • Enhanced isInterface to correctly identify *ast.InterfaceType nodes.
  • Improved error reporting in ParsePackage for syntax errors and empty Go file scenarios.
  • Refined error messages in ValuesOfType for cases like nil package input or type not found.

Describe your PR and link to any relevant issues.

This commit introduces new tests for the `internal/paramify` package, significantly increasing test coverage.

New test suites were added for:
- `ParsePackage`: Verifies package loading, including handling of non-existent directories, directories with no Go files, and files with syntax errors.
- `ValuesOfType`: Ensures correct extraction of required and optional fields from structs, covering a wide variety of field types (primitives, pointers, structs, arrays, maps, interfaces, any) and `omitempty` tags.

Enhancements were made to existing tests for:
- `isPointer`: Added cases for arrays of pointers and maps with pointer values.
- `isInterface`: Added cases for direct interface types and clarified behavior for aliases.
- `isOmitEmpty`: Added cases for tags with multiple options and unrelated tags.

During the process of adding these tests, the following improvements were also made to the source code:
- Enhanced `isInterface` to correctly identify `*ast.InterfaceType` nodes.
- Improved error reporting in `ParsePackage` for syntax errors and empty Go file scenarios.
- Refined error messages in `ValuesOfType` for cases like nil package input or type not found.
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