|
20 | 20 |
|
21 | 21 | DROP TABLE IF EXISTS `test`;
|
22 | 22 |
|
| 23 | +CREATE TABLE `test` ( |
| 24 | +`id` int(11) NOT NULL AUTO_INCREMENT, |
| 25 | +`created_at` date NOT NULL, |
| 26 | +`notes` varchar(255) NOT NULL, |
| 27 | +PRIMARY KEY (`id`) |
| 28 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; |
| 29 | +
|
23 | 30 | INSERT INTO `test` (`id`, `created_at`, `notes`) VALUES \
|
24 | 31 | (1,'2018-01-01','Test data 1'),\
|
25 | 32 | (2,'2018-01-02','Test data 2'),\
|
@@ -61,6 +68,31 @@ def test_sanitize_from_stream():
|
61 | 68 | """ in dump_output_lines
|
62 | 69 |
|
63 | 70 |
|
| 71 | +def test_skip_table_rows(): |
| 72 | + stream = io.BytesIO(MOCK_MYSQLDUMP_OUTPUT) |
| 73 | + config = Configuration() |
| 74 | + config.skip_rows_for_tables.append('test') |
| 75 | + |
| 76 | + output = list(sanitize_from_stream(stream, config)) |
| 77 | + |
| 78 | + assert output == [ |
| 79 | + '', |
| 80 | + '--- Fake MySQL database dump', |
| 81 | + '', |
| 82 | + 'DROP TABLE IF EXISTS `test`;', |
| 83 | + '', |
| 84 | + 'CREATE TABLE `test` (', |
| 85 | + '`id` int(11) NOT NULL AUTO_INCREMENT,', |
| 86 | + '`created_at` date NOT NULL,', |
| 87 | + '`notes` varchar(255) NOT NULL,', |
| 88 | + 'PRIMARY KEY (`id`)', |
| 89 | + ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;', |
| 90 | + '', |
| 91 | + '', |
| 92 | + '--- Final line after `INSERT INTO` statement.', |
| 93 | + ] |
| 94 | + |
| 95 | + |
64 | 96 | def test_sanitizer_invalid_input():
|
65 | 97 | stream = io.BytesIO(INVALID_MOCK_MYSQLDUMP_OUTPUT)
|
66 | 98 | config = Configuration()
|
|
0 commit comments