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

Support SQLite during tests #2539

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

jaulz
Copy link
Contributor

@jaulz jaulz commented Apr 9, 2024

  • Added or updated tests
  • Documented user facing changes
  • Updated CHANGELOG.md

Changes

This PR allows developers to easily use SQLite during testing without setting up a MySQL database.

Breaking changes

n/a

@jaulz jaulz changed the title test: support SQLite Support SQLite during tests Apr 9, 2024
@spawnia
Copy link
Collaborator

spawnia commented Apr 21, 2024

What are the steps to actually use SQLite testing? Do all tests pass with it?

@spawnia spawnia added the enhancement A feature or improvement label Apr 21, 2024
@jaulz
Copy link
Contributor Author

jaulz commented Apr 21, 2024

It's quite easy:

  • Create local database sqlite test (make sure you select anything, e.g. SELECT 1;, so it creates the file)
  • Add environment variable in phpunit.xml:
    <env name="LIGHTHOUSE_TEST_DB_DRIVER" value="sqlite"/>

Unfortunately, not all tests pass but they help me to develop in an environment (gitpod.io) to quickly iterate on ideas. These tests fail:

There were 3 failures:

1) Tests\Integration\Cache\CacheDirectiveTest::testCacheHasManyResolver
This query should only run once and be cached on the second run.
Failed asserting that 0 is identical to 1.

/workspace/lighthouse/tests/Integration/Cache/CacheDirectiveTest.php:397

2) Tests\Integration\Cache\CacheDirectiveTest::testAttachTagsToCache
This query should only run once and be cached on the second run.
Failed asserting that 0 is identical to 1.

/workspace/lighthouse/tests/Integration/Cache/CacheDirectiveTest.php:467

3) Tests\Integration\Schema\Directives\LikeDirectiveTest::testLikeClientWildcardsAreEscapedFromTemplate
Unable to find JSON fragment: 

[{"users":[{"name":"Aar%on"}]}]

within

[{"data":{"users":[]}}].
Failed asserting that false is true.

/workspace/lighthouse/vendor/laravel/framework/src/Illuminate/Testing/AssertableJsonString.php:142
/workspace/lighthouse/vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:761
/workspace/lighthouse/tests/Integration/Schema/Directives/LikeDirectiveTest.php:108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants