-
Notifications
You must be signed in to change notification settings - Fork 27
Support Container.with_privileged for Ryuk Privileged Mode
#221
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| defmodule Testcontainers.Util.PropertiesParserTest do | ||
| use ExUnit.Case, async: false | ||
|
|
||
| alias Testcontainers.Util.PropertiesParser | ||
|
|
||
| describe "read_property_sources/0" do | ||
| test "returns empty map when no files or env vars exist" do | ||
| # Clean env vars that might interfere | ||
| System.get_env() | ||
| |> Enum.filter(fn {k, _} -> String.starts_with?(k, "TESTCONTAINERS_") end) | ||
| |> Enum.each(fn {k, _} -> System.delete_env(k) end) | ||
|
|
||
| {:ok, props} = PropertiesParser.read_property_sources() | ||
|
|
||
| # Should at least return a map (may have project file props) | ||
| assert is_map(props) | ||
| end | ||
|
Comment on lines
+7
to
+17
|
||
|
|
||
| test "reads environment variables with TESTCONTAINERS_ prefix" do | ||
| System.put_env("TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED", "true") | ||
| System.put_env("TESTCONTAINERS_SOME_OTHER_PROPERTY", "value") | ||
|
|
||
| {:ok, props} = PropertiesParser.read_property_sources() | ||
|
|
||
| assert props["ryuk.container.privileged"] == "true" | ||
| assert props["some.other.property"] == "value" | ||
|
|
||
| # Cleanup | ||
| System.delete_env("TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED") | ||
| System.delete_env("TESTCONTAINERS_SOME_OTHER_PROPERTY") | ||
| end | ||
|
Comment on lines
+19
to
+31
|
||
|
|
||
| test "environment variables take precedence over file properties" do | ||
| # Set env var | ||
| System.put_env("TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED", "from_env") | ||
|
|
||
| {:ok, props} = PropertiesParser.read_property_sources() | ||
|
|
||
| # Env should win over any file-based setting | ||
| assert props["ryuk.container.privileged"] == "from_env" | ||
|
|
||
| # Cleanup | ||
| System.delete_env("TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED") | ||
| end | ||
|
Comment on lines
+33
to
+44
|
||
| end | ||
|
|
||
| describe "read_property_file/0" do | ||
| test "defaults to user file path" do | ||
| {:ok, props} = PropertiesParser.read_property_file() | ||
|
|
||
| # Should return a map (empty if user file doesn't exist) | ||
| assert is_map(props) | ||
| end | ||
| end | ||
|
|
||
| describe "read_property_file/1" do | ||
| test "reads properties from specified file" do | ||
| {:ok, props} = PropertiesParser.read_property_file("test/fixtures/.testcontainers.properties") | ||
|
|
||
| assert is_map(props) | ||
| assert props["tc.host"] == "tcp://localhost:9999" | ||
| end | ||
|
|
||
| test "returns empty map for nonexistent file" do | ||
| {:ok, props} = PropertiesParser.read_property_file("/nonexistent/path/.testcontainers.properties") | ||
|
|
||
| assert props == %{} | ||
| end | ||
| end | ||
| 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.
The documentation should follow the project's standard format by using a proper "## Returns" section header instead of inline text. This maintains consistency with other documented functions in the codebase (see lib/testcontainers.ex and lib/ecto.ex for examples).