test-ob-sqlite.el 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ;;; test-ob-sqlite.el --- tests for ob-sqlite.el -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2017, 2019 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 <https://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (org-test-for-executable "sqlite3")
  17. (unless (featurep 'ob-sqlite)
  18. (signal 'missing-test-dependency "Support for sqlite code blocks"))
  19. (ert-deftest ob-sqlite/table-variables-with-commas ()
  20. "Test of a table variable that contains commas. This guarantees that this code path results in a valid CSV."
  21. (should
  22. (equal '(("Mr Test A. Sql"
  23. "Minister for Science, Eternal Happiness, and Finance"))
  24. (org-test-with-temp-text
  25. "#+name: test_table1
  26. | \"Mr Test A. Sql\" | Minister for Science, Eternal Happiness, and Finance |
  27. #+begin_src sqlite :db /tmp/test.db :var tb=test_table1
  28. drop table if exists TestTable;
  29. create table TestTable(person, job);
  30. .mode csv TestTable
  31. .import $tb TestTable
  32. select * from TestTable;
  33. #+end_src"
  34. (org-babel-next-src-block)
  35. (org-babel-execute-src-block)))))
  36. (provide 'test-ob-sqlite)
  37. ;;; test-ob-sqlite.el ends here