-
Notifications
You must be signed in to change notification settings - Fork 185
Test create admin user #2266
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
Test create admin user #2266
Conversation
…qiange-fixcreateadmin
There was a problem hiding this 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 adds test coverage for the admin user creation logic and removes a guard that was preventing proper testing of this functionality. The tests verify that the default admin user is created only when necessary.
Key Changes
- Removed the
$FIRST_TIME_RUNguard in_init_user_admin()to allow admin user creation checks on every install call - Added
test_admin_no_need()to verify that the default 'admin' user is not created when another admin already exists - Added
test_default_admin()to verify that the default 'admin' user is created when no admin users exist
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/Ravada.pm | Removes the FIRST_TIME_RUN guard from _init_user_admin() to enable the admin creation logic to run on every _install() call, which is necessary for testing multiple scenarios |
| t/user/50_admin.t | Adds two new test functions to verify admin user creation behavior: one testing that admin is not created when unnecessary, and one testing that admin is created when needed |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $user = Ravada::Auth::SQL->new(name => 'admin'); | ||
| ok(!$user->id) or exit; | ||
| } | ||
|
|
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Missing description for the test function. Consider adding a comment to document what this test verifies:
# Test that default admin user is created when no admin exists
sub test_default_admin {| # Test that default admin user is created when no admin exists |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Tests create user when necessary and makes sure it is not created when another admin user is already there.