-
-
Notifications
You must be signed in to change notification settings - Fork 528
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 support for SQLite #1248
base: main
Are you sure you want to change the base?
Add support for SQLite #1248
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to borrow from the Rails CI template. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
services: | ||
<%- if using_postgres? -%> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this block be tested that it is present for Postgres and absent for SQLite? |
||
postgres: | ||
image: postgres | ||
env: | ||
|
@@ -94,6 +95,7 @@ jobs: | |
ports: | ||
- 5432:5432 | ||
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
<%- end %> | ||
|
||
# redis: | ||
# image: redis | ||
|
@@ -127,7 +129,9 @@ jobs: | |
- name: Run tests | ||
env: | ||
RAILS_ENV: test | ||
<%- if using_postgres? -%> | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432 | ||
<%- end -%> | ||
# REDIS_URL: redis://localhost:6379/0 | ||
<%- if using_rspec? -%> | ||
run: bin/rails db:setup spec | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ class CiGeneratorTest < Rails::Generators::TestCase | |
|
||
test "raises if PostgreSQL is not the adapter" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
with_database "unsupported" do | ||
assert_raises Suspenders::Generators::DatabaseUnsupported::Error, match: "This generator requires PostgreSQL" do | ||
assert_raises Suspenders::Generators::DatabaseUnsupported::Error, match: "This generator requires either PostgreSQL or SQLite" do | ||
run_generator | ||
|
||
assert_no_file app_root(".github/workflows/ci.yaml") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
require "test_helper" | ||
|
||
class Suspenders::GeneratorsTest < ActiveSupport::TestCase | ||
class HelpersTest < ActiveSupport::TestCase | ||
include Suspenders::TestHelpers | ||
include Suspenders::Generators::Helpers | ||
|
||
test "database_adapter returns the current database" do | ||
with_database "postgresql" do | ||
assert_equal database_adapter, "postgresql" | ||
end | ||
end | ||
Comment on lines
+8
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this also cover the SQLite case? |
||
end | ||
|
||
class APIAppUnsupportedTest < ActiveSupport::TestCase | ||
test "message returns a custom message" do | ||
expected = "This generator cannot be used on API only applications." | ||
|
@@ -11,7 +22,7 @@ class APIAppUnsupportedTest < ActiveSupport::TestCase | |
|
||
class DatabaseUnsupportedTest < ActiveSupport::TestCase | ||
test "message returns a custom message" do | ||
expected = "This generator requires PostgreSQL" | ||
expected = "This generator requires either PostgreSQL or SQLite" | ||
|
||
assert_equal expected, Suspenders::Generators::DatabaseUnsupported::Error.new.message | ||
end | ||
|
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.
I'm being a bit … careful (?) with my README changes here. I want to suggest it's possible, but we're just trying it out, and it's worth evaluating and not that you should necessarily switch away from Postgres.
That said, maybe we need an explicit example?
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.
Yeah, this is tricky, and I'm not sure the best approach to take. Suspenders is about limiting the choices we need to make, but I recognize we're in an exploratory phase.
I don't know if we have an explicit example (yet), but I imagine it would relate to avoiding a Platform as a service.