diff options
| author | Robert Pluim | 2018-07-17 13:10:21 +0200 |
|---|---|---|
| committer | Robert Pluim | 2018-07-17 13:10:21 +0200 |
| commit | f8d9d00b0e95a7a62cd4fe8483793c26c3b753db (patch) | |
| tree | 6dea1c829a2ce23476da7f0f7267d84fd3e59eb1 /test/src | |
| parent | adff0d5f75d4b3a74816527edb9ebe997c2089f3 (diff) | |
| download | emacs-f8d9d00b0e95a7a62cd4fe8483793c26c3b753db.tar.gz emacs-f8d9d00b0e95a7a62cd4fe8483793c26c3b753db.zip | |
Add tests for network-lookup-address-info
* test/src/process-tests.el (lookup-family-specification): Test
network-lookup-address-info api.
(lookup-unicode-domains): Test that unicode domains fail.
(lookup-google): Test that normal lookups succeed.
(non-existent-lookup-failure): Check that known non-existent
domains fail.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/process-tests.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 551b34ff371..2cc646e5a6c 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'ert) | 24 | (require 'ert) |
| 25 | (require 'puny) | ||
| 25 | 26 | ||
| 26 | ;; Timeout in seconds; the test fails if the timeout is reached. | 27 | ;; Timeout in seconds; the test fails if the timeout is reached. |
| 27 | (defvar process-test-sentinel-wait-timeout 2.0) | 28 | (defvar process-test-sentinel-wait-timeout 2.0) |
| @@ -215,5 +216,29 @@ | |||
| 215 | (string-to-list "stdout\n") | 216 | (string-to-list "stdout\n") |
| 216 | (string-to-list "stderr\n")))))) | 217 | (string-to-list "stderr\n")))))) |
| 217 | 218 | ||
| 219 | (ert-deftest lookup-family-specification () | ||
| 220 | "network-lookup-address-info should only accept valid family symbols." | ||
| 221 | (should-error (network-lookup-address-info "google.com" 'both)) | ||
| 222 | (should (network-lookup-address-info "google.com" 'ipv4)) | ||
| 223 | (should (network-lookup-address-info "google.com" 'ipv6))) | ||
| 224 | |||
| 225 | (ert-deftest lookup-unicode-domains () | ||
| 226 | "Unicode domains should fail" | ||
| 227 | (should-error (network-lookup-address-info "faß.de")) | ||
| 228 | (should (length (network-lookup-address-info (puny-encode-domain "faß.de"))))) | ||
| 229 | |||
| 230 | (ert-deftest lookup-google () | ||
| 231 | "Check that we can look up google IP addresses" | ||
| 232 | (let ((addresses-both (network-lookup-address-info "google.com")) | ||
| 233 | (addresses-v4 (network-lookup-address-info "google.com" 'ipv4)) | ||
| 234 | (addresses-v6 (network-lookup-address-info "google.com" 'ipv6))) | ||
| 235 | (should (length addresses-both)) | ||
| 236 | (should (length addresses-v4)) | ||
| 237 | (should (length addresses-v6)))) | ||
| 238 | |||
| 239 | (ert-deftest non-existent-lookup-failure () | ||
| 240 | "Check that looking up non-existent domain returns nil" | ||
| 241 | (should (eq nil (network-lookup-address-info "emacs.invalid")))) | ||
| 242 | |||
| 218 | (provide 'process-tests) | 243 | (provide 'process-tests) |
| 219 | ;; process-tests.el ends here. | 244 | ;; process-tests.el ends here. |