-
Notifications
You must be signed in to change notification settings - Fork 947
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
test: add test to images quiet flag #203
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package main | |
|
||
import ( | ||
"os/exec" | ||
"regexp" | ||
|
||
"github.com/go-check/check" | ||
) | ||
|
@@ -38,6 +39,20 @@ func (suite *PouchImagesSuite) TearDownTest(c *check.C) { | |
// TODO add cleanup work | ||
} | ||
|
||
// TestImagesQuietOption is to verify the quiet flag. | ||
func (suite *PouchImagesSuite) TestImagesQuietFlag(c *check.C) { | ||
qOut, _, err := runCmd(exec.Command("pouch", "images", "-q")) | ||
c.Assert(err, check.IsNil) | ||
|
||
quietOut, _, err := runCmd(exec.Command("pouch", "images", "--quiet")) | ||
c.Assert(err, check.IsNil) | ||
|
||
c.Assert(qOut, check.Equals, quietOut) | ||
if match, _ := regexp.MatchString("^[0-9a-f]+\n$", qOut); !match { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^[0-9a-f] : this may be changed to ^[0-9] as image ID only contains number. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @Letty5411 , the ID is short for SHA256-Digest which is hexadecimal. ID can contains the a-f. |
||
c.Fatalf("should return numeric ID, but got %s", qOut) | ||
} | ||
} | ||
|
||
// TestImagesWorks tests "pouch image" work. | ||
func (suite *PouchImagesSuite) TestImagesWorks(c *check.C) { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried these code by using
I think 123456789 is a valid image ID, but the regexp will not pass.
Am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ID is valid.
But the cli uses
fmt.Println
to print so that each ID will have theCarriage
char at the end.For the case, the qOut will contains the
\n
. That is why I put the\n
before the$
in the regrex.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, can we make pouchd pull an image in advance in the integration test of travisCI?
@sunyuan3 @Letty5411
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, the Windows uses
\r\n
as Carriage char. I don't have env to test that. 😢 The case maybe fail in Windows...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid no. But we have not planned running on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allencloud Yes, I can pull an image in advance in the integration test of travisCI.