Conversation
appleboy
commented
Mar 1, 2026
- Move authentication result and provider interface definitions into the new core package
- Update UserService, auth providers, and related code to use core.AuthProvider and core.AuthResult types
- Add GoMock generation for the core.AuthProvider interface
- Add tests for UserService authentication covering success, provider nil, wrong password, HTTP API provider, and user not found scenarios
- Move authentication result and provider interface definitions into the new core package - Update UserService, auth providers, and related code to use core.AuthProvider and core.AuthResult types - Add GoMock generation for the core.AuthProvider interface - Add tests for UserService authentication covering success, provider nil, wrong password, HTTP API provider, and user not found scenarios Signed-off-by: appleboy <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR refactors authentication type definitions and provider interfaces by moving them from the internal/auth package into the new internal/core package, making UserService depend on an interface (core.AuthProvider) rather than concrete types. It also adds GoMock generation for the new interface and new tests for the Authenticate method on UserService.
Changes:
- Introduces
core.AuthResultandcore.AuthProviderinterface in a newinternal/core/auth.gofile; makesauth.Resulta type alias for backward compatibility - Refactors
UserService,LocalAuthProvider,HTTPAPIAuthProvider, andbootstrap/providers.goto use the newcore.AuthProviderinterface - Adds a GoMock-generated
MockAuthProviderand six new unit tests forUserService.Authenticate
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/core/auth.go |
New file defining AuthResult struct and AuthProvider interface |
internal/auth/types.go |
Replaces auth.Result struct with a type alias to core.AuthResult |
internal/auth/local.go |
Adds compile-time interface compliance assertion |
internal/auth/http_api.go |
Adds compile-time interface compliance assertion |
internal/services/user.go |
Changes localProvider/httpAPIProvider fields and constructor params from concrete types to core.AuthProvider interface |
internal/bootstrap/providers.go |
Returns core.AuthProvider interface instead of concrete pointer to avoid the typed-nil interface pitfall |
internal/mocks/mock_auth.go |
Generated MockAuthProvider mock for use in tests |
internal/mocks/generate.go |
Adds go:generate directive for mock_auth.go |
internal/services/user_test.go |
Adds six tests for UserService.Authenticate covering local and HTTP API scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.