Merge "Added check for negative segment-size"
This commit is contained in:
		| @@ -763,6 +763,9 @@ def st_upload(parser, args, output_manager): | ||||
|                 return | ||||
|  | ||||
|             options.segment_size = str((1024 ** size_mod) * multiplier) | ||||
|         if int(options.segment_size) <= 0: | ||||
|             output_manager.error("segment-size should be positive") | ||||
|             return | ||||
|  | ||||
|     _opts = vars(options) | ||||
|     _opts['object_uu_threads'] = options.object_threads | ||||
|   | ||||
| @@ -899,6 +899,29 @@ class TestShell(unittest.TestCase): | ||||
|                     swiftclient.shell.main(argv) | ||||
|                 self.assertEquals(output.err, "Invalid segment size\n") | ||||
|  | ||||
|     def test_negative_upload_segment_size(self): | ||||
|         with CaptureOutput() as output: | ||||
|             with ExpectedException(SystemExit): | ||||
|                 argv = ["", "upload", "-S", "-40", "container", "object"] | ||||
|                 swiftclient.shell.main(argv) | ||||
|             self.assertEquals(output.err, "segment-size should be positive\n") | ||||
|             output.clear() | ||||
|             with ExpectedException(SystemExit): | ||||
|                 argv = ["", "upload", "-S", "-40K", "container", "object"] | ||||
|                 swiftclient.shell.main(argv) | ||||
|             self.assertEquals(output.err, "segment-size should be positive\n") | ||||
|             output.clear() | ||||
|             with ExpectedException(SystemExit): | ||||
|                 argv = ["", "upload", "-S", "-40M", "container", "object"] | ||||
|                 swiftclient.shell.main(argv) | ||||
|             self.assertEquals(output.err, "segment-size should be positive\n") | ||||
|             output.clear() | ||||
|             with ExpectedException(SystemExit): | ||||
|                 argv = ["", "upload", "-S", "-40G", "container", "object"] | ||||
|                 swiftclient.shell.main(argv) | ||||
|             self.assertEquals(output.err, "segment-size should be positive\n") | ||||
|             output.clear() | ||||
|  | ||||
|  | ||||
| class TestSubcommandHelp(unittest.TestCase): | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jenkins
					Jenkins