branch: externals/gnosis
commit ecfcb7a830f6b07ac919785517250af7aa2f8faa
Author: Thanos Apollo <[email protected]>
Commit: Thanos Apollo <[email protected]>

    tests: Update for new schemata and add new tag tests.
---
 tests/gnosis-test-dashboard.el | 14 +++-----------
 tests/gnosis-test-helpers.el   |  4 +++-
 tests/gnosis-test-nodes.el     |  6 +-----
 tests/gnosis-test-sqlite.el    |  4 ++--
 4 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/tests/gnosis-test-dashboard.el b/tests/gnosis-test-dashboard.el
index e549020fa9..760ba08fbe 100644
--- a/tests/gnosis-test-dashboard.el
+++ b/tests/gnosis-test-dashboard.el
@@ -44,14 +44,6 @@ Stubs `pop-to-buffer-same-window' so tests work in batch 
mode."
   "Insert a link from THEMA-ID to NODE-ID string."
   (gnosis--insert-into 'thema-links `([,thema-id ,node-id])))
 
-(defun gnosis-test--setup-tags ()
-  "Populate tags table from existing themata in test DB."
-  (let ((tags (gnosis-get-tags--unique)))
-    (gnosis-sqlite-with-transaction gnosis-db
-      (cl-loop for tag in tags
-               do (condition-case nil
-                      (gnosis--insert-into 'thema-tags `[,tag])
-                    (error nil))))))
 
 ;; ──────────────────────────────────────────────────────────
 ;; Pure function tests
@@ -324,7 +316,7 @@ Stubs `pop-to-buffer-same-window' so tests work in batch 
mode."
     (let ((deck-id (gnosis-test--add-deck "test-deck")))
       (gnosis-test--add-basic-thema deck-id "Q1" "A1" '("math"))
       (gnosis-test--add-basic-thema deck-id "Q2" "A2" '("geo"))
-      (gnosis-test--setup-tags)
+
       (gnosis-test-with-dashboard-buffer
         (gnosis-dashboard-output-tags)
         (with-current-buffer gnosis-dashboard-buffer-name
@@ -342,7 +334,7 @@ Stubs `pop-to-buffer-same-window' so tests work in batch 
mode."
   (gnosis-test-with-db
     (let* ((deck-id (gnosis-test--add-deck "test-deck"))
            (id1 (gnosis-test--add-basic-thema deck-id "Q1" "A1" '("math"))))
-      (gnosis-test--setup-tags)
+
       (gnosis-test-with-dashboard-buffer
         ;; Start in themata mode
         (gnosis-dashboard-output-themata (list id1))
@@ -472,7 +464,7 @@ Binds `gnosis-nodes-dir' to the temp directory."
     (let ((deck-id (gnosis-test--add-deck "test-deck")))
       (gnosis-test--add-basic-thema deck-id "Q1" "A1" '("math"))
       (gnosis-test--add-basic-thema deck-id "Q2" "A2" '("geo"))
-      (gnosis-test--setup-tags)
+
       (gnosis-test-with-dashboard-buffer
         (gnosis-dashboard-output-tags)
         (with-current-buffer gnosis-dashboard-buffer-name
diff --git a/tests/gnosis-test-helpers.el b/tests/gnosis-test-helpers.el
index eb67176347..188701e205 100644
--- a/tests/gnosis-test-helpers.el
+++ b/tests/gnosis-test-helpers.el
@@ -67,7 +67,9 @@ SUSPEND: 1 to suspend, 0 or nil for active."
       (gnosis--insert-into 'review-log `([,id ,(gnosis-algorithm-date)
                                               ,(gnosis-algorithm-date) 0 0 0 0
                                               ,suspend 0]))
-      (gnosis--insert-into 'extras `([,id ,parathema ""])))
+      (gnosis--insert-into 'extras `([,id ,parathema ""]))
+      (cl-loop for tag in tags
+              do (gnosis--insert-into 'thema-tag `([,id ,tag]))))
     id))
 
 (provide 'gnosis-test-helpers)
diff --git a/tests/gnosis-test-nodes.el b/tests/gnosis-test-nodes.el
index e6fe023b95..f286913a76 100644
--- a/tests/gnosis-test-nodes.el
+++ b/tests/gnosis-test-nodes.el
@@ -168,10 +168,7 @@ Content with [[id:other-node][a link]].
             '(["n1" "test.org" "Title" 0 "nil" "0" "abc"]))
           (gnosis--insert-into 'journal
             '(["j1" "journal.org" "Entry" 1 "nil" "0" "def"]))
-          (ignore-errors
-            (gnosis--insert-into 'node-tags '(["tag1"])))
-          (ignore-errors
-            (gnosis--insert-into 'node-tag '(["n1" "tag1"])))
+          (gnosis--insert-into 'node-tag '(["n1" "tag1"]))
           ;; Verify data exists
           (should (= 1 (length (gnosis-nodes-select '* 'nodes nil))))
           (should (= 1 (length (gnosis-nodes-select '* 'journal nil))))
@@ -180,7 +177,6 @@ Content with [[id:other-node][a link]].
           ;; All empty
           (should (null (gnosis-nodes-select '* 'nodes nil)))
           (should (null (gnosis-nodes-select '* 'journal nil)))
-          (should (null (gnosis-nodes-select '* 'node-tags nil)))
           (should (null (gnosis-nodes-select '* 'node-tag nil)))))
     (gnosis-test-nodes--teardown-dirs)))
 
diff --git a/tests/gnosis-test-sqlite.el b/tests/gnosis-test-sqlite.el
index 9a40eeb1f1..7dadf34d7f 100644
--- a/tests/gnosis-test-sqlite.el
+++ b/tests/gnosis-test-sqlite.el
@@ -291,10 +291,10 @@ Value is pre-encoded (prin1-to-string) in the compiler."
 ;;; ---- Group 6: Values compiler ----
 
 (ert-deftest gnosis-test-sqlite-values-single-vector ()
-  "Single vector compiles to (?, ?, ?)."
+  "Single vector compiles to (?, ?, ?) with encoded params."
   (let ((result (gnosis-sqlite--compile-values [1 "hello" nil])))
     (should (equal (car result) "(?, ?, ?)"))
-    (should (equal (cdr result) '(1 "hello" nil)))))
+    (should (equal (cdr result) '(1 "\"hello\"" nil)))))
 
 ;;; ---- Group 7: Integration tests ----
 

Reply via email to