This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify DefaultDockerClientUnitTest
refactor this test to use a MockWebServer rather than mocking the Jersey/jax-rs Client interface used by the DefaultDockerClient. Using a (Mockito) mock Client is problematic for a test since it has such a rich and fluent interface - the test needs to know exactly which methods are called on the Client. Ultimately, this is not what a unit test of DefaultDockerClient should care about - a good test would only care about what HTTP requests it sends to the Docker Remote API and how it behaves when it gets certain HTTP responses back. The MockWebServer allows us to control the HTTP responses and capture the HTTP requests much easier than using a Mockito mock of the particular HTTP client library used by DefaultDockerClient. With this approach, it would be possible to one day change DefaultDockerClient to use a different HTTP client library without having to change one line of this test. The same cannot be said of using Mockito. This change was initially driven by a desire to make PR #749 easier to test, to check that it sends expected authentication headers, but I think it will be useful and help improve testing in docker-client across the board. https://github.com/square/okhttp/tree/master/mockwebserver
- Loading branch information
Showing
3 changed files
with
84 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters