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 full-stack test for MySQL #69

Closed
jdegoes opened this issue Sep 8, 2020 · 11 comments · Fixed by #321
Closed

Add full-stack test for MySQL #69

jdegoes opened this issue Sep 8, 2020 · 11 comments · Fixed by #321

Comments

@jdegoes
Copy link
Member

jdegoes commented Sep 8, 2020

Depends on #149

We need a full-stack test for MySQL.

We need an automated ZIO Test that, when run, will execute a simple query, such as select 1, against a live-running MySQL, and verify the result set returned from the query.

This full-stack test will be the foundation for adding other more complicated tests.

This can follow the established pattern from PostgresModuleTest.

@andrewhj
Copy link
Contributor

I'll give this one a shot

@andrewhj
Copy link
Contributor

Looking at how PostgresqlModule is done, it appears would be duplicate logic (particularly utilities like TestContainer). Would it make sense to move TestContainer to a more common location? Would jdbc be the appropriate module?

@andrewhj
Copy link
Contributor

I've been unable to figure out the scala/zio syntax to perform a "select 1" call. I think I'm missing something simple. The (still unworking) syntax I thought made sense was
select(constant(1)).
However, this yields an error: Cannot prove that query.ResultType <:< (Integer, Unit).

In my branch I have test container setup for mysql and enough code in place to get a table selection test working so if anyone can offer some guidance (here or on discord) I'd love to get this example put together and merged.

@andrewhj
Copy link
Contributor

@jdegoes
Copy link
Member Author

jdegoes commented Nov 23, 2020

@andrewhj I am not sure what problem you're running into here, but we will investigate and fix!

@andrewhj
Copy link
Contributor

I managed to get a table select test working (just not the simple "select 1" case). I will clean up & submit PR for that case.

@robmwalsh
Copy link
Contributor

robmwalsh commented Nov 25, 2020

@andrewhj at the moment we need to select from a table, which is probably not ideal, but is the way that the syntax is currently implemented ( from memory select returns a SelectBuilder which has a function from(table: Table) which is what actually returns a Read.Select, which is the type that we need to execute a query. It's possible to fix this but probably not high on the priority list given there's a simple workaround; use select(1) from customers instead of select 1. I'll create an issue for this anyway. created #323

@andrewhj
Copy link
Contributor

makes sense. 1 thing to consider (at least on postgres and mysql), is that you'll get a set back equal in size to the table you select. If customer has 5 rows, you'll get back 5 rows of 1. However, if customer is empty, you will get back an empty set (instead of 1).

@robmwalsh
Copy link
Contributor

Right, I didn't think of that! In that case it should probably be a higher priority. In the meantime you can follow the other tests and just take the first returned value (or you can have a shot at fixing the issue - happy to provide assistance if needed)

@jdegoes
Copy link
Member Author

jdegoes commented Nov 25, 2020 via email

@robmwalsh
Copy link
Contributor

robmwalsh commented Nov 25, 2020

I meant higher priority only in that it'd mean simpler/faster tests for all the glorified calculator style tests we have to run. Once all the PRs are merged I think I'll go through and tidy them up, break into suites etc; I can take care of it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants