Ver código fonte

unit tests!?

jordyn 2 anos atrás
pai
commit
9e81b38f7c
2 arquivos alterados com 56 adições e 3 exclusões
  1. 4 3
      photogal.el
  2. 52 0
      test-photogal.el

+ 4 - 3
photogal.el

@@ -1,3 +1,4 @@
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;    PHOTOGAL    ;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; v1.0 ;;;;;;
@@ -143,7 +144,8 @@ for all tags defined -- one function per tag."
     (if (or tag-code-too-long tag-code-in-use)
 	(progn (message "tag code must be a single character and can't be already in use")
 	       (call-interactively 'photogal-add-tag))
-      (photogal--add-tag new-tag new-tag-code))))
+      (photogal--add-tag new-tag new-tag-code)
+      (photogal-refresh-buffer))))
 
 (defun photogal-delete-tag (tag-code)
   "Remove a tag from the library."
@@ -159,8 +161,7 @@ for all tags defined -- one function per tag."
     (customize-save-variable
      'photogal/tags
      (cons (cons new-tag-code escaped-str-tag) photogal/tags)))
-  (photogal-generate-tag-commands)
-  (photogal-refresh-buffer))
+  (photogal-generate-tag-commands))
 
 (defun photogal-tag-code-in-use (tag-code)
   (seq-contains-p

+ 52 - 0
test-photogal.el

@@ -0,0 +1,52 @@
+
+
+(load "/Users/jwd/code/photo-gal/photogal.el")
+
+(setq photogaltest-example-operating-table
+      '(("/Photos/comp.png"
+	 (nil nil))
+	("/Photos/e06de5-5501,240622--_art_computer_good_meme_photography_politics_portrait_reaction-photo_screenshot_selfie_.png"
+	 (nil nil))
+	("/Photos/e99e1a-5501,240622-como-_art_cityscape_computer_family_meme_politics_reaction-photo_screenshot_selfie_.jpg"
+	 (nil nil))
+	("/Photos/rsf.png"
+	 (nil nil))))
+
+(ert-deftest file-properties-test ()
+
+  (let
+      ((*photogal/operating-table*
+	photogaltest-example-operating-table))
+
+    (should (eq (photogal-get-tags-for-file "/Photos/comp.png")
+		'()))
+    (should   (eq (photogal-get-name-for-file "/Photos/comp.png")
+		  nil))
+
+    ;; ADD THE TAG TO THE SYSTEM
+    (photogal--add-tag "on" "o")
+
+    ;; TOGGLE THE FLAG ON FOR A PHOTO
+    (photogal-for-file-toggle-tag "/Photos/comp.png" "on")   
+    (should (equal (photogal-get-tags-for-file "/Photos/comp.png")
+		   '("on")))
+
+    ;; TOGGLE IT BACK OFF
+    (photogal-for-file-toggle-tag "/Photos/comp.png" "on")
+    (should (eq (photogal-get-tags-for-file "/Photos/comp.png")
+		'()))))
+
+
+
+(ert-deftest folder-sorting-test ()
+
+  (let
+      ((*photogal/operating-table*
+	photogaltest-example-operating-table))
+
+    (should (eq (photogal-get-folder-for-file "/Photos/comp.png")
+		""))
+
+    ))
+
+