Skip to content

Conversation

@frankiejol
Copy link
Member

Tests create user when necessary and makes sure it is not created when another admin user is already there.

Copilot AI review requested due to automatic review settings December 3, 2025 12:49
@frankiejol frankiejol added this to the v2.4.3 milestone Dec 3, 2025
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 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_RUN guard 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;
}

Copy link

Copilot AI Dec 3, 2025

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 {
Suggested change
# Test that default admin user is created when no admin exists

Copilot uses AI. Check for mistakes.
frankiejol and others added 2 commits December 3, 2025 13:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@frankiejol frankiejol merged commit 9eefcf2 into main Dec 3, 2025
1 check 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.

3 participants