| 1 | module main |
| 2 | |
| 3 | fn test_get_server_urls_from_args_supports_all_flags() { |
| 4 | args := ['install', '-server-url', 'https://one.example/', '--server-url', |
| 5 | ' https://two.example ', '--server-urls', 'https://one.example'] |
| 6 | server_urls := get_server_urls_from_args(args) |
| 7 | assert server_urls == ['https://one.example', 'https://two.example'] |
| 8 | } |
| 9 | |
| 10 | fn test_get_mirror_urls_from_args_supports_short_and_long_flags() { |
| 11 | args := ['install', '-m', 'https://mirror1.example/', '--mirror', 'https://mirror2.example', |
| 12 | '-m', 'https://mirror1.example'] |
| 13 | mirror_urls := get_mirror_urls_from_args(args) |
| 14 | assert mirror_urls == ['https://mirror1.example', 'https://mirror2.example'] |
| 15 | } |
| 16 | |
| 17 | fn test_build_install_server_urls_prioritizes_default_servers() { |
| 18 | server_urls := build_install_server_urls(['https://official1.example', |
| 19 | 'https://official2.example'], ['https://mirror1.example', 'https://official2.example']) |
| 20 | assert server_urls == ['https://official1.example', 'https://official2.example', |
| 21 | 'https://mirror1.example'] |
| 22 | } |
| 23 | |
| 24 | fn test_metadata_server_urls_uses_selected_server() { |
| 25 | mut selector := VpmInstallServerSelector{ |
| 26 | candidate_urls: ['https://official.example', 'https://mirror.example'] |
| 27 | } |
| 28 | assert selector.metadata_server_urls() == ['https://official.example', 'https://mirror.example'] |
| 29 | selector.selected_url = 'https://mirror.example' |
| 30 | assert selector.metadata_server_urls() == ['https://mirror.example'] |
| 31 | } |
| 32 | |