-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add unit tests to plugin create/remove/enable/disable commands #878
Add unit tests to plugin create/remove/enable/disable commands #878
Conversation
Codecov Report
@@ Coverage Diff @@
## master #878 +/- ##
==========================================
- Coverage 53.19% 52.67% -0.52%
==========================================
Files 246 257 +11
Lines 16021 16403 +382
==========================================
+ Hits 8522 8640 +118
- Misses 6929 7190 +261
- Partials 570 573 +3 |
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.
Thanks! Just one comment to make the assertions on stdout more strict.
cli/command/plugin/create_test.go
Outdated
err = setupPluginDir(tmpDir, []byte("invalid-config-contents")) | ||
if err != nil { | ||
t.Fatal(err) | ||
} |
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.
This can be do with (gotestyourself/fs
):
tmpDir := fs.NewDir(t, "plugin-create-test",
fs.WithDir("rootfs",
fs.WithFile("config.json", "invalid-config-contents")))
defer tmpDir.Remove()
Just as an FYI, I think this works for now.
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.
Thank you for the review. The gotestyourself
looks very interesting (just taking a look at the above example, it reads much better than the function I wrote for these tests).
If you are OK with such a change, I can change to use gotestyourself/fs
here.
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.
That would be great, thanks!
cli/command/plugin/create_test.go
Outdated
cmd := newCreateCommand(cli) | ||
cmd.SetArgs([]string{"plugin-foo", tmpDir}) | ||
assert.NoError(t, cmd.Execute()) | ||
assert.Equal(t, "plugin-foo", strings.TrimSpace(cli.OutBuffer().String())) |
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 think we should check the stdout without TrimSpace()
. The trailing newline is important.
There's a few instances of this below as well.
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.
Thanks for the review. I have updated the PR accordingly.
…rk on docker#37 Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
e147ce2
to
0a914da
Compare
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.
LGTM, thanks!
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.
LGTM 🌵
add tests to plugin create/remove/enable/disable commands. Part of work on #37
Signed-off-by: Arash Deshmeh adeshmeh@ca.ibm.com
- What I did
Added unit tests to several plugin commands (create/remove/enable/disable)
- How I did it
Added tests in create_test.go, remove_test.go, enable_test.go, disable_test.go
- How to verify it
Run the test suite:
make -f docker.Makefile test
- Description for the changelog
Added unit tests to plugin create/remove/enable/disable commands.
- A picture of a cute animal (not mandatory but encouraged)