-
Notifications
You must be signed in to change notification settings - Fork 61
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
Annotation to load SQL before a test @Sql #851
Conversation
Would it be too crazy to allow this annotation in other than tests? (at my own risk). I can imagine using it for some of my demos on the |
test-junit5/src/main/java/io/micronaut/test/extensions/junit5/MicronautJunit5Extension.java
Outdated
Show resolved
Hide resolved
test-junit5/src/main/java/io/micronaut/test/extensions/junit5/MicronautJunit5Extension.java
Outdated
Show resolved
Hide resolved
test-junit5/src/main/java/io/micronaut/test/extensions/junit5/MicronautJunit5Extension.java
Outdated
Show resolved
Hide resolved
If you already working on this code, maybe you can take a look and rewrite the code:
To read the annotations from the bean definition, allowing for meta annotations. |
test-core/src/main/java/io/micronaut/test/support/sql/TestSqlAnnotationHandler.java
Outdated
Show resolved
Hide resolved
If we want to do that, we need to decide now as this means the annotation would need a different place to live. And a different mechanism to invoke it @micronaut-projects/core-developers do people have thoughts on this? |
I think we could keep However, We could create a similar feature to load data on startup, such as the |
@sdelamo that would work perfectly, yes |
Out of curiosity, what is the the benefit of doing this vs using a |
I assume by injection you mean loading of sql file into the database. What do you mean by "this"? Using @Inject
Connection connection;
@Inject
ResourceLoader resourceLoader;
@BeforeEach
void setUp() throws IOException, SQLException {
SqlUtils.load(connection, resourceLoader, "sql/seed-data.sql");
} |
We need the properties before we have an application context, which means before we have a |
I think I have a way of supporting R2DBC... Working on it |
I need to investigate the implicit MicronautTest transactions... I think I need to move where we do the Sql injection... |
@dstepanov could you take another look? It supports R2dbc now... Not sure if we need method level annotation... We can set method level transactions in |
...e/src/main/java/io/micronaut/test/support/sql/processor/R2DBCConnectionFactoryProcessor.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/processor/SqlDataSourceProcessor.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/processor/SqlScriptProcessor.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/resolver/CompositeDataSourceResolver.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/resolver/DataSourceResolver.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/resolver/DefaultDataSourceResolver.java
Outdated
Show resolved
Hide resolved
...-core/src/main/java/io/micronaut/test/support/sql/resolver/DelegatingDataSourceResolver.java
Outdated
Show resolved
Hide resolved
...ore/src/main/java/io/micronaut/test/support/sql/resolver/R2DBCConnectionFactoryResolver.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/processor/SqlDataSourceProcessor.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/resolver/CompositeDataSourceResolver.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/resolver/DefaultDataSourceResolver.java
Outdated
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/DelegatingDataSourceSqlHandler.java
Show resolved
Hide resolved
test-core/src/main/java/io/micronaut/test/support/sql/SqlHandler.java
Outdated
Show resolved
Hide resolved
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 added the nullability annotations to SqlHandler
Thanks! Sorry I missed them in the rewrite 😞 |
* add test-suite-at-sql-jpa module * add tests * change hikari * fix id * rollback SQL * add insert * Add rollback to the annotation * Switch to allow phases * Docs --------- Co-authored-by: Tim Yates <tim.yates@gmail.com>
SonarCloud Quality Gate failed. 0 Bugs 63.2% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Started with Spock support
Closes #832