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

RtContainersTestCase.java:33-35: Write unit tests for all... #47

Closed
0pdd opened this issue Mar 13, 2018 · 13 comments
Closed

RtContainersTestCase.java:33-35: Write unit tests for all... #47

0pdd opened this issue Mar 13, 2018 · 13 comments
Labels
bug Something isn't working

Comments

@0pdd
Copy link
Collaborator

0pdd commented Mar 13, 2018

The puzzle 26-a8980bc9 from #26 has to be resolved:

* @todo #26:30min Write unit tests for all the methods of RtContainers.
* AssertRequest should be passed in the ctor, with the right expected
* response and predicates.

The puzzle was created by amihaiemil on 13-Mar-18.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

@0crat
Copy link
Collaborator

0crat commented Mar 14, 2018

Job #47 is now in scope, role is DEV

@0crat
Copy link
Collaborator

0crat commented Mar 14, 2018

The job #47 assigned to @llorllale/z, here is why. The budget is 30 minutes, see §4. Please, read §8 and §9. If the task is not clear, read this and this.

@llorllale
Copy link
Contributor

@amihaiemil what's the url?

@param container Json config as specified in the API's docs.

Would be nice if we added to the javadocs:

@see <a href="api_doc_url">Docker API</a>

@amihaiemil
Copy link
Owner

@llorllale right; this is the URL: https://docs.docker.com/engine/api/v1.30/#operation/ContainerCreate

The API docs is for 1.30; I guess it won't change that much in future versions. Besides, whoever knows how to read it will also know to check the right version they need :)

@llorllale
Copy link
Contributor

llorllale commented Mar 14, 2018

@amihaiemil I'm think about creating Response that implements HttpResponse in order to support tests. WDYT?

The idea is to provide an easy way to specify an HttpResponse to the AssertRequest ctor.

eg.:

new AssertRequest(
    new Response(HttpStatus.SC_OK, "json_payload"),
    conditions...
)

@llorllale
Copy link
Contributor

@amihaiemil here's an example of what this might all look like:

    /**
     * Should create container if request valid and no error is returned from
     * the Docker API.
     * 
     * @throws Exception unexpected
     */
    @Test
    public void createContainerFromImageName() throws Exception {
        MatcherAssert.assertThat(
            new RtContainers(
                new AssertRequest(
                    new Response(
                        HttpStatus.SC_CREATED, "{ \"Id\": \"df2419f4\" }"
                    ),
                    new Condition(
                        "The 'Content-Type' header must be set.",
                        req -> req.getHeaders("Content-Type").length > 0
                    ),
                    new Condition(
                        "Content-Type must be 'application/json'.",
                        // @checkstyle LineLength (1 line)
                        req -> "application/json".equals(req.getHeaders("Content-Type")[0].getValue())
                    ),
                    new Condition(
                        "Resource path must be /containers/create",
                        // @checkstyle LineLength (1 line)
                        req -> req.getRequestLine().getUri().endsWith("/containers/create")
                    )
                ), URI.create("http://localhost/test")
            ).create("some_image"),
            Matchers.notNullValue()
        );
    }

@amihaiemil
Copy link
Owner

@llorllale Yeah, seems like a good idea :)

llorllale added a commit to llorllale/docker-java-api that referenced this issue Mar 15, 2018
* Added some tests for RtContainers
* Added new test support classes 'Response' and 'PayloadOf'
* Fixed typo in 'ContainerCreate' API endpoint in RtContainers
llorllale added a commit to llorllale/docker-java-api that referenced this issue Mar 16, 2018
As per PR review:
* Fixed javadoc for PayloadOf
* Fixed endpoint test for RtContainers
@0pdd
Copy link
Collaborator Author

0pdd commented Mar 16, 2018

The puzzle 26-a8980bc9 has disappeared from the source code, that's why I closed this issue.

@0pdd
Copy link
Collaborator Author

0pdd commented Mar 16, 2018

@0pdd 2 puzzles #53, #54 are still not solved.

@0crat
Copy link
Collaborator

0crat commented Mar 16, 2018

Order was finished: +30 points just awarded to @llorllale/z

@0crat
Copy link
Collaborator

0crat commented Mar 16, 2018

The job #47 is now out of scope

@0pdd
Copy link
Collaborator Author

0pdd commented Mar 20, 2018

@0pdd the puzzle #54 is still not solved; solved: #53.

@0pdd
Copy link
Collaborator Author

0pdd commented Mar 24, 2018

@0pdd all 2 puzzles are solved here: #53, #54.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants