Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces/mount: make Change.Perform testable and test it #3971
Conversation
codecov-io
commented
Sep 27, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #3971 +/- ##
==========================================
+ Coverage 75.71% 75.75% +0.03%
==========================================
Files 424 424
Lines 36608 36607 -1
==========================================
+ Hits 27717 27730 +13
+ Misses 6945 6931 -14
Partials 1946 1946
Continue to review full report at Codecov.
|
| -type changeSuite struct{} | ||
| +type changeSuite struct { | ||
| + sys *mount.SyscallRecorder | ||
| + restore func() |
stolowski
Oct 3, 2017
Contributor
Since you suggested similar thing to me today (and I kind like that) ;), let's use BaseTest and get rid of restore before it grows
| +func (s *changeSuite) TestPerformMount(c *C) { | ||
| + chg := &mount.Change{Action: mount.Mount, Entry: mount.Entry{Name: "source", Dir: "target", Type: "type"}} | ||
| + err := chg.Perform() | ||
| + c.Assert(err, IsNil) |
stolowski
Oct 3, 2017
Contributor
c.Assert(chg.Perform(), IsNil)
applies to asserts further down too.
zyga
added some commits
Oct 3, 2017
|
@stolowski both done now |
| + | ||
| +// Change.Perform returns errors from unmount system call | ||
| +func (s *changeSuite) TestPerformUnountError(c *C) { | ||
| + s.sys.InsertFault(`unmount "target" 8`, errTesting) |
mvo5
Oct 4, 2017
Collaborator
Maybe a comment like above: // The flag 8 is UMOUNT_NOFOLLOW ? I also wonder if there is a way to make this easier to read in the tests. Not sure how hard it would be to resolve the flags in the recorder to symbolic names?
zyga commentedSep 27, 2017
•
Edited 1 time
-
zyga
Oct 5, 2017
This patch adds the necessary system call mocking to Change.Perform
and adds a complementary suite of unit tests for all code paths.
This is a preparation step for increasing the complexity of Perform.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com