testcontainers / testcontainers/testcontainers-java

[Enhancement]: ScriptUtils::runInitScript should load script also from local directory

Open
#7,257 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/enhancement
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 (or test-compile) phase must have run, but what if I want to use testcontainers in the generate-sources (or generate-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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.