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 tests for secrets in BuildxCLI to show that they are optional #651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import tarfile
from pathlib import Path
from unittest.mock import Mock, patch

import pytest

Expand Down Expand Up @@ -85,6 +87,24 @@ def test_buildx_build_streaming_logs(tmp_path):
assert line != ""


@patch("python_on_whales.components.buildx.cli_wrapper.stream_stdout_and_stderr")
@pytest.mark.usefixtures("with_docker_driver")
def test_buildx_secrets(ssas: Mock, tmp_path: Path):
(tmp_path / "Dockerfile").write_text(dockerfile_content1)
list(docker.buildx.build(tmp_path, stream_logs=True))
assert "--secret" not in ssas.call_args[0][0]
list(docker.buildx.build(tmp_path, secrets="secret1", stream_logs=True))
assert "--secret" in ssas.call_args[0][0] and "secret1" in ssas.call_args[0][0]
list(
docker.buildx.build(tmp_path, secrets=["secret1", "secret2"], stream_logs=True)
)
assert (
"--secret" in ssas.call_args[0][0]
and "secret1" in ssas.call_args[0][0]
and "secret2" in ssas.call_args[0][0]
)


@pytest.mark.usefixtures("with_docker_driver")
def test_buildx_build_streaming_logs_with_decode_error_handling(tmp_path):
# This will simulate buildx clipping log output in the middle of a UTF-8 character
Expand Down
Loading