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

Compatibility problem in Testcontainers when run test in windows #103

Open
sahara468 opened this issue Apr 1, 2024 · 0 comments
Open

Compatibility problem in Testcontainers when run test in windows #103

sahara468 opened this issue Apr 1, 2024 · 0 comments

Comments

@sahara468
Copy link

sahara468 commented Apr 1, 2024

When i follow https://wiremock.readthedocs.io/en/latest/testcontainers/ run test in Windows with DockerDesktop use WSL2 based engine, it throws docker.errors.NotFound: 404 Client Error, details:

  File "D:\Program Files\Python312\Lib\site-packages\docker\api\client.py", line 267, in _raise_for_status
    raise create_api_error_from_http_exception(e) from e
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Program Files\Python312\Lib\site-packages\docker\errors.py", line 39, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation) from e
docker.errors.NotFound: 404 Client Error for http://localhost:2375/v1.43/containers/42abf343b127c20a5c2de82a90d42c782449db7d8e10dd5cd7585804402ef686/archive?path=%5Chome%5Cwiremock%5Cmappings: Not Found ("Could not find the file \home\wiremock\mappings in container 42abf343b127c20a5c2de82a90d42c782449db7d8e10dd5cd7585804402ef686")

The problem seems here, it shouldn't be a WindowsPath, this will cause the wrong url generated, so should convert to posix format by call Path("").as_posix()

    def copy_mappings_to_container(self) -> None:
        """Copies all mappings files generated with
        `.with_mapping('hello-world.json', {...})` to the container under
        the configured MAPPINGS_DIR
        """

        self.copy_files_to_container(
            # shouldn't be a WindowsPath here, call as_posix() can fix this problem
            configs=self.mapping_stubs, container_dir_path=Path(f"{self.MAPPINGS_DIR}")
        )

    def copy_mapping_files_to_container(self) -> None:
        """Copies all mappings files generated with
        `.with_file('hello.json', {...})` to the container under
        the configured FILES_DIR
        """
        self.copy_files_to_container(
            # shouldn't be a WindowsPath here, call as_posix() can fix this problem
            configs=self.mapping_files, container_dir_path=Path(f"{self.FILES_DIR}")
        )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant