Skip to content

Comments

fix: dynamic module name in test templates#1181

Merged
hwbrzzl merged 3 commits intogoravel:masterfrom
BadJacky:fix/dynamic-module-name-in-test-templates
Sep 5, 2025
Merged

fix: dynamic module name in test templates#1181
hwbrzzl merged 3 commits intogoravel:masterfrom
BadJacky:fix/dynamic-module-name-in-test-templates

Conversation

@BadJacky
Copy link
Contributor

@BadJacky BadJacky commented Sep 3, 2025

📑 Description

Closes https://github.com/goravel/goravel/issues/

Replace hardcoded "goravel" module import in test templates with
dynamic module name detection using debug.ReadBuildInfo().

  • Add GetModuleName() method to Make struct
  • Update populateStub() to accept and replace DummyModule placeholder
  • Update test template stub to use DummyModule instead of hardcoded path
  • Add test verification for correct module import path
  • Fallback to "goravel" if build info unavailable

This ensures generated test files use correct import paths regardless
of the actual module name, improving framework reusability.

✅ Checks

  • Added test cases for my code

- Add DateTimes method to Blueprint interface
- Implement DateTimes method to create created_at and updated_at columns
- Add precision parameter support for timestamp columns
- Add test coverage for DateTimes functionality
Replace hardcoded "goravel" module import in test templates with
dynamic module name detection using debug.ReadBuildInfo().

- Add GetModuleName() method to Make struct
- Update populateStub() to accept and replace DummyModule placeholder
- Update test template stub to use DummyModule instead of hardcoded path
- Add test verification for correct module import path
- Fallback to "goravel" if build info unavailable

This ensures generated test files use correct import paths regardless
of the actual module name, improving framework reusability.
@BadJacky BadJacky requested a review from a team as a code owner September 3, 2025 17:11
@codecov
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.85%. Comparing base (be764d1) to head (ad777e7).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
support/console/console.go 0.00% 5 Missing ⚠️
foundation/console/test_make_command.go 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1181      +/-   ##
==========================================
+ Coverage   68.83%   68.85%   +0.01%     
==========================================
  Files         230      230              
  Lines       14879    14885       +6     
==========================================
+ Hits        10242    10249       +7     
  Misses       4238     4238              
+ Partials      399      398       -1     

☔ 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.

@hwbrzzl hwbrzzl requested a review from Copilot September 5, 2025 03:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a hardcoded module import issue in test template generation by replacing the static "goravel" module reference with dynamic module name detection. The change ensures that generated test files use the correct import paths based on the actual module name rather than assuming "goravel".

  • Added GetModuleName() method to dynamically detect module name using debug.ReadBuildInfo()
  • Updated test template generation to replace DummyModule placeholder with actual module name
  • Modified test stub to use dynamic module placeholder instead of hardcoded "goravel" path

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
support/console/console.go Adds GetModuleName() method with build info detection and fallback
foundation/console/test_make_command.go Updates populateStub to handle module name replacement
foundation/console/stubs.go Changes hardcoded import to DummyModule placeholder
foundation/console/test_make_command_test.go Adds test verification for correct module import path

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch!

@hwbrzzl hwbrzzl merged commit 03c8390 into goravel:master Sep 5, 2025
15 of 16 checks passed
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