Skip to content
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

Add case-insensitive collation settings to SQLite test database #2868

Open
G3mha opened this issue Nov 21, 2024 · 0 comments
Open

Add case-insensitive collation settings to SQLite test database #2868

G3mha opened this issue Nov 21, 2024 · 0 comments
Labels
area/database This issue is caused by a problem in the database kind/bug Something isn't working

Comments

@G3mha
Copy link
Contributor

G3mha commented Nov 21, 2024

Describe the bug

Originated during discussion of PR #2854

SQLite test database uses case-sensitive collation while production MySQL uses case-insensitive, causing test failures for case-insensitive string operations.

To Reproduce
Steps to reproduce the behavior:

  1. Go to file tests/Feature/Api/V1/UserSummaryTest.php and add the following test case:
public function testUsernameCaseConsistency(): void
{
    $user = User::factory()->create([
        'User' => 'NicoPlaysThings',
    ]);
    $variations = [
        'NICOPLAYSTHINGS',
        'nicoplaysthings',
        'NicoPlaysThings',
    ];

    foreach ($variations as $input) {
        $response = $this->get($this->apiUrl('GetUserSummary', ['u' => $input]));
        $response->assertOk()
                ->assertJsonPath('User', 'NicoPlaysThings')
                ->assertJsonPath('LastActivity.User', 'NicoPlaysThings')
                ->assertJsonPath('UserPic', '/UserPic/NicoPlaysThings.png');
    }
}
  1. Run the test involving case-insensitive username lookups:
php artisan test tests/Feature/Api/V1/UserSummaryTest.php --filter testUsernameCaseConsistency
  1. Observe test failure due to collation mismatch
  2. See PR fix(API_GetUserSummary): handle username case sensitivity and use canonical username #2854 for the complete discussion on this error

Expected behavior

  • SQLite test database should use case-insensitive collation matching MySQL's behavior
  • Tests should pass regardless of username case variations
  • UserSummary API tests should succeed with usernames like 'NICOPLAYSTHINGS', 'nicoplaysthings', 'NicoPlaysThings'

Additional context

@wescopeland wescopeland added kind/bug Something isn't working area/database This issue is caused by a problem in the database labels Nov 21, 2024
@wescopeland wescopeland changed the title fix(tests): Add case-insensitive collation settings to SQLite test database Add case-insensitive collation settings to SQLite test database Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/database This issue is caused by a problem in the database kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants