branch: master commit 60d9d90841b90aa8019b554b5038e21156bedc64 Author: Ian Dunn <du...@gnu.org> Commit: Ian Dunn <du...@gnu.org>
Added tests for interface selection * enwc-test.el (enwc-test-select-interface-save): Test for selecting interface using ip and saving the interface. (enwc-test-select-interface-no-save): Test for selecting interface using ifconfig and not saving the interface. --- enwc-test.el | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/enwc-test.el b/enwc-test.el new file mode 100644 index 0000000..5b3c6f1 --- /dev/null +++ b/enwc-test.el @@ -0,0 +1,66 @@ +;;; enwc-test.el --- Tests for ENWC + +;; Copyright (C) 2012-2017 Free Software Foundation, Inc. + +;; Author: Ian Dunn <du...@gnu.org> +;; Keywords: external, network, wicd, manager, nm +;; Version: 2.0 +;; Package-Requires: ((emacs "25.1")) +;; Homepage: https://savannah.nongnu.org/p/enwc + +;;; Commentary: + +;;; Code: + +(require 'enwc) +(require 'ert) + +;; Test enwc-setup + +(ert-deftest enwc-test-select-interface-save () + ;; Test saving the interfaces and using the ip selection back-end + (let ((enwc-interface-list-function 'enwc--ip-interface-list) + (enwc-ask-to-save-interfaces t) + ;; Temporarily save our changes to a different file + (custom-file (make-temp-file "enwc-custom-")) + (enwc-wired-device "") + (enwc-wireless-device "")) + (enwc--setup-select-interfaces) + (should (not (string-empty-p enwc-wired-device))) + (should (not (string-empty-p enwc-wireless-device))) + ;; Test whether the interfaces were saved + (let ((enwc-wired-device "") + (enwc-wireless-device "")) + (load custom-file) + (should (not (string-empty-p enwc-wired-device))) + (should (not (string-empty-p enwc-wireless-device)))) + ;; Delete our temporary custom file + (delete-file custom-file))) + +(ert-deftest enwc-test-select-interface-no-save () + ;; Test not saving the interfaces and using the ifconfig selection back-end + (let ((enwc-interface-list-function 'enwc--ifconfig-interface-list) + (enwc-ask-to-save-interfaces nil) + ;; Temporarily save our "changes" to a different file + (custom-file (make-temp-file "enwc-custom-")) + (enwc-wired-device "") + (enwc-wireless-device "")) + (enwc--setup-select-interfaces) + (should (not (string-empty-p enwc-wired-device))) + (should (not (string-empty-p enwc-wireless-device))) + ;; Test whether the interfaces were saved + (let ((enwc-wired-device "") + (enwc-wireless-device "")) + (load custom-file) + (should (string-empty-p enwc-wired-device)) + (should (string-empty-p enwc-wireless-device))) + ;; Delete our temporary custom file + (delete-file custom-file))) + +(provide 'enwc-test) + +;; Local Variables: +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; enwc-test.el ends here