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

cli/command/container: set empty args in tests and discard output #5534

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

thaJeztah
Copy link
Member

cli/command/container: set empty args in tests and discard output

Prevent some tests from failing when running from a pre-compiled testbinary, and discard output to make the output less noisy.

cli/command/container: TestWaitExitOrRemoved use subtests

=== RUN   TestWaitExitOrRemoved
=== RUN   TestWaitExitOrRemoved/normal-container
=== RUN   TestWaitExitOrRemoved/give-me-exit-code-42
=== RUN   TestWaitExitOrRemoved/i-want-a-wait-error
time="2024-10-13T18:48:14+02:00" level=error msg="Error waiting for container: removal failed"
=== RUN   TestWaitExitOrRemoved/non-existent-container-id
time="2024-10-13T18:48:14+02:00" level=error msg="error waiting for container: no such container: non-existent-container-id"
--- PASS: TestWaitExitOrRemoved (0.00s)
    --- PASS: TestWaitExitOrRemoved/normal-container (0.00s)
    --- PASS: TestWaitExitOrRemoved/give-me-exit-code-42 (0.00s)
    --- PASS: TestWaitExitOrRemoved/i-want-a-wait-error (0.00s)
    --- PASS: TestWaitExitOrRemoved/non-existent-container-id (0.00s)
PASS

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.92%. Comparing base (31eeed7) to head (35d7b1a).
Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5534      +/-   ##
==========================================
+ Coverage   60.53%   60.92%   +0.39%     
==========================================
  Files         342      345       +3     
  Lines       23483    23491       +8     
==========================================
+ Hits        14216    14313      +97     
+ Misses       8292     8205      -87     
+ Partials      975      973       -2     

@thaJeztah thaJeztah changed the title cli/command/container: set empty args in tests and discard output Beta cli/command/container: set empty args in tests and discard output Oct 13, 2024
Comment on lines 63 to 66
for _, tc := range tests {
t.Run(tc.cid, func(t *testing.T) {
client := &fakeClient{waitFunc: waitFn, Version: api.DefaultVersion}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now using a separate client per test – was that an intentional change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; not really (I think I contemplated "parallel" tests for a second, but the overhead thereof didn't make much sense for this).

Let me change that back

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurazard updated; PTAL

Prevent some tests from failing when running from a pre-compiled
testbinary, and discard output to make the output less noisy.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    === RUN   TestWaitExitOrRemoved
    === RUN   TestWaitExitOrRemoved/normal-container
    === RUN   TestWaitExitOrRemoved/give-me-exit-code-42
    === RUN   TestWaitExitOrRemoved/i-want-a-wait-error
    time="2024-10-13T18:48:14+02:00" level=error msg="Error waiting for container: removal failed"
    === RUN   TestWaitExitOrRemoved/non-existent-container-id
    time="2024-10-13T18:48:14+02:00" level=error msg="error waiting for container: no such container: non-existent-container-id"
    --- PASS: TestWaitExitOrRemoved (0.00s)
        --- PASS: TestWaitExitOrRemoved/normal-container (0.00s)
        --- PASS: TestWaitExitOrRemoved/give-me-exit-code-42 (0.00s)
        --- PASS: TestWaitExitOrRemoved/i-want-a-wait-error (0.00s)
        --- PASS: TestWaitExitOrRemoved/non-existent-container-id (0.00s)
    PASS

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@laurazard laurazard merged commit dba4b15 into docker:master Oct 16, 2024
89 checks passed
@thaJeztah thaJeztah deleted the container_testfixes branch October 16, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants