testcontainers / testcontainers/testcontainers-java
[Enhancement]: ScriptUtils::runInitScript should load script also from local directory
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
Module
Core
Proposal
The ScriptUtils::runInitScript only accepts paths from the classpath. This isn't as powerful as I would have expected given:
- Absolute paths or relative paths local to the maven module, for example, are useful as well
- Being on the classpath means the Maven
compile(ortest-compile) phase must have run, but what if I want to use testcontainers in thegenerate-sources(orgenerate-test-sources) phase, e.g. to generate jOOQ code? In that case, the init scripts aren't available on the classpath yet, unless I create a separate module just for this, which is overkill
Additionally, there are many cases where the script doesn't have to be a file. An inline script in String form would suffice, e.g.
container.initScript("""
create schema test;
create table test.test (test int);
""");
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ScriptUtils::runInitScript and the container.initScript API mentioned in the proposal. Trace how classpath scripts are resolved, then determine how local absolute or relative paths and inline String scripts should be accepted. Done means each supported input form works, with tests covering local paths and inline SQL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100