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

Update integration test integration-cli/docker_cli_rmi_test.go with Assert #16901

Merged
merged 1 commit into from
Oct 16, 2015

Conversation

WeiZhang555
Copy link
Contributor

Part of #16756

Update integration-cli/docker_cli_rmi_test.go:
Use Assert instead of condition judgement in test.

Signed-off-by: Zhang Wei zhangwei555@huawei.com

@@ -266,6 +236,12 @@ func (s *DockerSuite) TestRmiBlank(c *check.C) {
if !strings.Contains(out, "image name cannot be blank") {
c.Fatalf("Expected error message not generated: %s", out)
}
// Should have failed to delete '' image
Copy link
Contributor

Choose a reason for hiding this comment

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

seems forget to remove the

if err == nil {
}
if string.Contians{
}
if !string.Contains{
}

up there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. 👍

@WeiZhang555 WeiZhang555 force-pushed the rmi-inte branch 2 times, most recently from d9e5817 to c60e9bf Compare October 10, 2015 06:33
c.Fatalf("failed to create a container: %s, %v", out, err)
}
// failed to create a container
c.Assert(err, checker.IsNil, check.Commentf("out: %s", out))
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can use dockerCmd instead of dockerCmdWithError here, so that the assert for err is no need any more.

Copy link
Member

Choose a reason for hiding this comment

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

Completely true, should use dockerCmd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean that use

out, _ := dockerCmd("run", "-d", "busybox", "true")

to replace

out, _, err := dockerCmdWithError("run", "-d", "busybox", "true")
c.Assert(err, checker.IsNil, check.Commentf("out: %s", out))

If so, do you really think it's OK to ignore failure of docker run? I really doubt it...

Copy link
Member

Choose a reason for hiding this comment

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

@WeiZhang555 yes it is ! You don't ignore failure of docker run, they are "handled" in dockerCmd (see https://github.com/docker/docker/blob/master/pkg/integration/dockerCmd_utils.go#L33, there is an Assert on the err 😉)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got your point, that's very clear.
Will update. :)

Part of moby#16756

Update integration-cli/docker_cli_rmi_test.go:
Use Assert instead of condition judgement in test.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
@WeiZhang555
Copy link
Contributor Author

@vdemeester refreshed per your suggestion, please help check if this is OK now, thank you :)

// Container is using image, should not be able to rmi
c.Assert(err, checker.NotNil)
// Container is using image, error message should contain errSubstr
c.Assert(out, checker.Contains, errSubstr, check.Commentf("Container: %q", cleanedContainerID))
Copy link
Member

Choose a reason for hiding this comment

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

I would have kept the comment that was in c.Fatalf in a check.Commentf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we have discussed in #16854, comment above c.Assert statement will be printed out together with check.Commentf, do you still see a need to put comment in check.Commentf?
@vdemeester

Copy link
Member

Choose a reason for hiding this comment

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

Nop, that's ok 😉.

@vdemeester
Copy link
Member

Sorry couple of more comments and we should be good to go 😉

@vdemeester
Copy link
Member

LGTM 🐼

@WeiZhang555 WeiZhang555 changed the title Update integration test with Assert Update integration test integration-cli/docker_cli_rmi_test.go with Assert Oct 12, 2015
@WeiZhang555
Copy link
Contributor Author

Any more progress ?

@calavera
Copy link
Contributor

LGTM

calavera added a commit that referenced this pull request Oct 16, 2015
Update integration test `integration-cli/docker_cli_rmi_test.go` with Assert
@calavera calavera merged commit ec7c368 into moby:master Oct 16, 2015
@WeiZhang555 WeiZhang555 deleted the rmi-inte branch October 17, 2015 13:42
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.

5 participants