Closed kezhuw closed 8 years ago
can we have some tests to make sure this is always correct?
the change LGTM but I'd like to be sure that we cover all cases with our tests.
New test is added in commit f21b2d4 to break old code. Seems that no ci build happened for that commit. I paste error message from my local environment:
➜ go-units git:(f21b2d4) go test
--- FAIL: TestParseUlimitInvalidValueType (0.00s)
ulimit_test.go:65: expected error on bad value type, but got `ulimit soft limit must be less than or equal to hard limit: 1024 > 0`
FAIL
exit status 1
FAIL github.com/docker/go-units 0.007s
Commit d4a9b96 passes this test as the ci build shows.
Thank you, merging!
Two problems exist in old code:
if len(limitVals) > 2
never evaluates to true, because ofstrings.SplitN(s, sep string, n int)
will return at most n substrings when n > 0.err
is ignored in parsing hard limitation value. Thus we may get inaccurate error message when invalid hard limitation value encountered.Signed-off-by: Kezhu Wang kezhuw@gmail.com