test-ob-sqlite.el 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ;;; test-ob-sqlite.el --- tests for ob-sqlite.el
  2. ;; Copyright (C) 2017 Eduardo Bellani
  3. ;; Author: Eduardo Bellani <ebellani@gmail.com>
  4. ;; Keywords: lisp
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (org-test-for-executable "sqlite3")
  17. (require 'ob-sqlite)
  18. (unless (featurep 'ob-sqlite)
  19. (signal 'missing-test-dependency "Support for sqlite code blocks"))
  20. (ert-deftest ob-sqlite/table-variables-with-commas ()
  21. "Test of a table variable that contains commas. This garantees that this code path results in a valid CSV."
  22. (should
  23. (equal '(("Mr Test A. Sql"
  24. "Minister for Science, Eternal Happiness, and Finance"))
  25. (org-test-with-temp-text
  26. "#+name: test_table1
  27. | \"Mr Test A. Sql\" | Minister for Science, Eternal Happiness, and Finance |
  28. #+begin_src sqlite :db /tmp/test.db :var tb=test_table1
  29. drop table if exists TestTable;
  30. create table TestTable(person, job);
  31. .mode csv TestTable
  32. .import $tb TestTable
  33. select * from TestTable;
  34. #+end_src"
  35. (org-babel-next-src-block)
  36. (org-babel-execute-src-block)))))
  37. ;;; test-ob-sqlite.el ends here