|
9 | 9 |
|
10 | 10 | REPOSITORY_URL = "https://github.com/pathway-labs/airbyte-to-deltalake" |
11 | 11 | TRACKED_REPOSITORY_URL = "https://github.com/pathwaycom/pathway/" |
| 12 | +IDENTITY_PROGRAM = os.path.join(os.path.dirname(__file__), "identity.py") |
12 | 13 |
|
13 | 14 |
|
14 | 15 | def count_commits_in_pathway_repository(tmp_path): |
@@ -42,3 +43,104 @@ def test_repository_url_feature(tmp_path): |
42 | 43 | expected_n_commits = count_commits_in_pathway_repository(tmp_path) |
43 | 44 |
|
44 | 45 | assert actual_n_commits == expected_n_commits |
| 46 | + |
| 47 | + |
| 48 | +def invoke_spawn(runner, args): |
| 49 | + return runner.invoke( |
| 50 | + cli.spawn, args + ["python", IDENTITY_PROGRAM, "input.txt", "output.jsonl"] |
| 51 | + ) |
| 52 | + |
| 53 | + |
| 54 | +def test_processes_and_addresses_are_mutually_exclusive(runner): |
| 55 | + result = invoke_spawn( |
| 56 | + runner, ["--processes", "2", "--addresses", "host0:10000,host1:10000"] |
| 57 | + ) |
| 58 | + assert result.exit_code != 0 |
| 59 | + assert "--processes and --addresses are mutually exclusive" in result.output |
| 60 | + |
| 61 | + |
| 62 | +def test_process_id_requires_addresses(runner): |
| 63 | + result = invoke_spawn(runner, ["--process-id", "1"]) |
| 64 | + assert result.exit_code != 0 |
| 65 | + assert "--process-id requires --addresses" in result.output |
| 66 | + |
| 67 | + |
| 68 | +def test_addresses_requires_process_id(runner): |
| 69 | + result = invoke_spawn(runner, ["--addresses", "host0:10000,host1:10000"]) |
| 70 | + assert result.exit_code != 0 |
| 71 | + assert "--process-id is required when --addresses is set" in result.output |
| 72 | + |
| 73 | + |
| 74 | +def test_address_invalid_format_no_colon(runner): |
| 75 | + result = invoke_spawn(runner, ["--addresses", "host010000", "--process-id", "0"]) |
| 76 | + assert result.exit_code != 0 |
| 77 | + assert "expected host:port format" in result.output |
| 78 | + |
| 79 | + |
| 80 | +def test_address_invalid_format_non_numeric_port(runner): |
| 81 | + result = invoke_spawn(runner, ["--addresses", "host0:abc", "--process-id", "0"]) |
| 82 | + assert result.exit_code != 0 |
| 83 | + assert "expected host:port format" in result.output |
| 84 | + |
| 85 | + |
| 86 | +def test_address_port_zero(runner): |
| 87 | + result = invoke_spawn(runner, ["--addresses", "host0:0", "--process-id", "0"]) |
| 88 | + assert result.exit_code != 0 |
| 89 | + assert "must be in range" in result.output |
| 90 | + |
| 91 | + |
| 92 | +def test_address_port_too_large(runner): |
| 93 | + result = invoke_spawn(runner, ["--addresses", "host0:99999", "--process-id", "0"]) |
| 94 | + assert result.exit_code != 0 |
| 95 | + assert "must be in range" in result.output |
| 96 | + |
| 97 | + |
| 98 | +def test_addresses_duplicate_entries(runner): |
| 99 | + result = invoke_spawn( |
| 100 | + runner, |
| 101 | + ["--addresses", "host0:10000,host0:10000", "--process-id", "0"], |
| 102 | + ) |
| 103 | + assert result.exit_code != 0 |
| 104 | + assert "duplicate entries" in result.output |
| 105 | + |
| 106 | + |
| 107 | +def test_process_id_out_of_range(runner): |
| 108 | + result = invoke_spawn( |
| 109 | + runner, |
| 110 | + ["--addresses", "host0:10000,host1:10000", "--process-id", "5"], |
| 111 | + ) |
| 112 | + assert result.exit_code != 0 |
| 113 | + assert "--process-id 5 is out of range" in result.output |
| 114 | + |
| 115 | + |
| 116 | +def test_process_id_negative(runner): |
| 117 | + result = invoke_spawn( |
| 118 | + runner, |
| 119 | + ["--addresses", "host0:10000,host1:10000", "--process-id", "-1"], |
| 120 | + ) |
| 121 | + assert result.exit_code != 0 |
| 122 | + assert "--process-id -1 is out of range" in result.output |
| 123 | + |
| 124 | + |
| 125 | +def test_threads_zero(runner): |
| 126 | + result = invoke_spawn(runner, ["--threads", "0"]) |
| 127 | + assert result.exit_code != 0 |
| 128 | + assert "--threads must be at least 1" in result.output |
| 129 | + |
| 130 | + |
| 131 | +def test_threads_negative(runner): |
| 132 | + result = invoke_spawn(runner, ["--threads", "-4"]) |
| 133 | + assert result.exit_code != 0 |
| 134 | + assert "--threads must be at least 1" in result.output |
| 135 | + |
| 136 | + |
| 137 | +def test_processes_zero(runner): |
| 138 | + result = invoke_spawn(runner, ["--processes", "0"]) |
| 139 | + assert result.exit_code != 0 |
| 140 | + assert "--processes must be at least 1" in result.output |
| 141 | + |
| 142 | + |
| 143 | +def test_first_port_overflow(runner): |
| 144 | + result = invoke_spawn(runner, ["--processes", "3", "--first-port", "65534"]) |
| 145 | + assert result.exit_code != 0 |
| 146 | + assert "exceeds the maximum" in result.output |
0 commit comments