-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rewrite app/checks/disk-space to python, change the syntax #3
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3 +/- ##
======================================
Coverage 80.1% 80.1%
======================================
Files 8 8
Lines 196 196
Branches 22 22
======================================
Hits 157 157
Misses 35 35
Partials 4 4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #3 +/- ##
======================================
Coverage 80.1% 80.1%
======================================
Files 8 8
Lines 196 196
Branches 22 22
======================================
Hits 157 157
Misses 35 35
Partials 4 4
Continue to review full report at Codecov.
|
Thanks for the pull request. The test is failing because the mocking no longer works. You can rewrite the test also to Python if you would like to use Python unittest's mock. |
i'm pretty sure that the test is broken since it wants to assert that 4GB is enough when 4.5GB is the defined minimum. This commit fixes it and also makes check/disk-space work properly with mock values. |
if free_space >= req_space: | ||
print("There is {0:.1f}{1} disk space at {2}, nothing to worry about, defined minimum is {3}{1}".format(free_space, unit, mntpoint, req_space)) | ||
return 0 | ||
else: |
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.
You do not need the else there. This practice is called early return.
if free_space >= req_space:
print("There is {0:.1f}{1} disk space at {2}, nothing to worry about, defined minimum is {3}{1}".format(free_space, unit, mntpoint, req_space))
return 0
print("Failed asserting that {0:.1f}{1} is at least {2}{1} at {3}".format(free_space, unit, req_space, mntpoint))
return 1
😉
Approved, one non-critical comment left. Can be merged, and the improvement can be applied with a next PR 😉 |
Rewrite of disk-space health check. Uses sys.statvfs (unix system call) now, also the syntax has changed from using env variables to using argv as a means to get dir and required space.