aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/sql-tests.el
diff options
context:
space:
mode:
authorSimen Heggestøyl2017-08-09 15:34:34 +0200
committerSimen Heggestøyl2017-09-05 20:31:21 +0200
commitfca62384537e1a32e867f4d3181e0b2b79396383 (patch)
treec6586fb7df23770b3f2f7763a9d3337c05653285 /test/lisp/progmodes/sql-tests.el
parent25a49f64963d1c2a392ebaa66676042b55e0e3c1 (diff)
downloademacs-fca62384537e1a32e867f4d3181e0b2b79396383.tar.gz
emacs-fca62384537e1a32e867f4d3181e0b2b79396383.zip
Handle non-zero exit status from psql more gracefully
* lisp/progmodes/sql.el (sql-postgres-list-databases): Handle non-zero exit statuses from `psql -ltX' more gracefully by returning nil. * test/lisp/progmodes/sql-tests.el (sql-tests-postgres-list-databases-error): New test.
Diffstat (limited to 'test/lisp/progmodes/sql-tests.el')
-rw-r--r--test/lisp/progmodes/sql-tests.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/lisp/progmodes/sql-tests.el b/test/lisp/progmodes/sql-tests.el
index 27a72aa2c23..f75005f737f 100644
--- a/test/lisp/progmodes/sql-tests.el
+++ b/test/lisp/progmodes/sql-tests.el
@@ -43,5 +43,15 @@
43 (should (equal (sql-postgres-list-databases) 43 (should (equal (sql-postgres-list-databases)
44 '("db-name-1" "db_name_2"))))) 44 '("db-name-1" "db_name_2")))))
45 45
46(ert-deftest sql-tests-postgres-list-databases-error ()
47 "Test that nil is returned when `psql -ltX' fails."
48 (cl-letf
49 (((symbol-function 'executable-find)
50 (lambda (_command) t))
51 ((symbol-function 'process-lines)
52 (lambda (_program &rest _args)
53 (error))))
54 (should-not (sql-postgres-list-databases))))
55
46(provide 'sql-tests) 56(provide 'sql-tests)
47;;; sql-tests.el ends here 57;;; sql-tests.el ends here