-
-
Notifications
You must be signed in to change notification settings - Fork 161
qrlogin: fix Export method to handle all AuthExportLoginToken response types #1571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1571 +/- ##
==========================================
- Coverage 69.00% 68.75% -0.25%
==========================================
Files 443 443
Lines 21530 21545 +15
==========================================
- Hits 14856 14813 -43
- Misses 5740 5787 +47
- Partials 934 945 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…sponse types The Export method now properly handles all possible response types from AuthExportLoginToken: - AuthLoginToken: normal case, returns new token - AuthLoginTokenSuccess: token already accepted, returns error - AuthLoginTokenMigrateTo: migration needed, returns MigrationNeededError Previously only AuthLoginToken was handled, which could cause unexpected type errors.
AuthLoginTokenSuccess indicates successful authentication, not an error. Return empty token instead of error when login token was already accepted.
…d for AuthLoginTokenSuccess case
- Add tests for MigrationNeededError.Error method (0% -> 100%) - Add tests for OnLoginToken function (0% -> 100%) - Add tests for Token.Image method (0% -> 75%) - Add tests for Import method with migration scenarios (43.5% -> 82.6%) - Overall coverage improved from 67.0% to 84.6%
📝 Changes Made✅ Fixed Commit MessagesFixed all commit messages to follow Conventional Commits standard as required by commitlint:
📊 Significantly Improved Test CoverageAdded comprehensive tests to address codecov feedback: Overall coverage: Method-specific improvements:
🧪 New Tests Added
🎯 Coverage Issues AddressedThis PR addresses the codecov report showing 42.10% patch coverage with 11 missing lines. The new tests specifically target the previously uncovered code paths in:
The commitlint check should now pass ✅ and codecov coverage should be significantly improved 📈 |
…eived When Export returns empty token (AuthLoginTokenSuccess case), Auth method should wait for the loggedIn signal before calling Import, ensuring proper synchronization with the login flow and fixing test failures on macOS Go 1.23.
Problem
The Export method in qrlogin package only handled *tg.AuthLoginToken response type from AuthExportLoginToken API call, but the API can return other types like *tg.AuthLoginTokenSuccess and *tg.AuthLoginTokenMigrateTo, which would cause "unexpected type" errors.
Solution
Added proper handling for all possible response types:
Changes
This fix prevents runtime panics when AuthExportLoginToken returns unexpected (but valid) response types.