[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy d03bd70 068/133: Added unit-test for uploads
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy d03bd70 068/133: Added unit-test for uploads |
Date: |
Sat, 27 Mar 2021 14:48:45 -0400 (EDT) |
branch: externals/ssh-deploy
commit d03bd70346ade5a7ef7b22e1cd3b8fa84c58f4c2
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Added unit-test for uploads
---
ssh-deploy-test.el | 103 +++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 93 insertions(+), 10 deletions(-)
diff --git a/ssh-deploy-test.el b/ssh-deploy-test.el
index a9dc06b..b380a6f 100644
--- a/ssh-deploy-test.el
+++ b/ssh-deploy-test.el
@@ -57,18 +57,26 @@
(file-b (expand-file-name "test-b" directory-b))
(file-b-contents "Random text")
(ssh-deploy-root-local directory-a)
- (ssh-deploy-root-remote directory-b))
+ (ssh-deploy-root-remote directory-b)
+ (ssh-deploy-on-explicit-save 0)
+ (ssh-deploy-async 0)
+ (ssh-deploy-verbose 0)
+ (ssh-deploy-debug 0))
+ ;; Just bypass the linter here
(when (and ssh-deploy-root-local
- ssh-deploy-root-remote)
+ ssh-deploy-root-remote
+ ssh-deploy-on-explicit-save
+ ssh-deploy-async
+ ssh-deploy-verbose
+ ssh-deploy-debug)
- ;; Create a new file and add it's contents
- (find-file file-b)
- (insert file-b-contents)
- (save-buffer)
+ (let ((old-default-directory default-directory))
- ;; Visit local root
- (let ((default-directory directory-a))
+ ;; Create a new file and add it's contents
+ (find-file file-b)
+ (insert file-b-contents)
+ (save-buffer)
;; Download file
(ssh-deploy-download file-b file-a 0 nil 0)
@@ -77,8 +85,82 @@
(should (equal t (ediff-same-file-contents file-a file-b)))
(delete-file file-b)
- (delete-file file-a))))
-
+ (delete-file file-a)
+
+ ;; (find-file) changes default-directory so we revert it here
+ (setq default-directory old-default-directory))))
+
+ (delete-directory directory-a t)
+ (delete-directory directory-b t)))
+
+(defun ssh-deploy-test--upload ()
+ "Test uploads."
+
+ (require 'ediff-util)
+
+ (let ((directory-a (expand-file-name "test-a/"))
+ (directory-b (expand-file-name "test-b/")))
+
+ ;; Delete directories if they already exists
+ (when (file-directory-p directory-a)
+ (delete-directory directory-a t))
+ (when (file-directory-p directory-b)
+ (delete-directory directory-b t))
+
+ (make-directory-internal directory-a)
+ (make-directory-internal directory-b)
+
+ (let* ((file-a (expand-file-name "test.txt" directory-a))
+ (file-b (expand-file-name "test.txt" directory-b))
+ (file-a-contents "Random text")
+ (ssh-deploy-root-local directory-a)
+ (ssh-deploy-root-remote directory-b)
+ (ssh-deploy-on-explicit-save 1)
+ (ssh-deploy-async 0)
+ (ssh-deploy-verbose 0)
+ (ssh-deploy-debug 0))
+
+ ;; Just bypass the linter here
+ (when (and ssh-deploy-root-local
+ ssh-deploy-root-remote
+ ssh-deploy-on-explicit-save
+ ssh-deploy-async
+ ssh-deploy-verbose
+ ssh-deploy-debug)
+
+ ;; Create a new file and add it's contents
+ (let ((old-default-directory default-directory))
+
+ (ssh-deploy-add-after-save-hook)
+ (find-file file-a)
+ (insert file-a-contents)
+ (save-buffer) ;; NOTE Should trigger upload action
+
+ ;; Verify that both files have equal contents
+ (should (equal t (ediff-same-file-contents file-a file-b)))
+
+ ;; Turn of automatic uploads
+ (let ((ssh-deploy-on-explicit-save 0))
+
+ ;; Update should not trigger upload
+ (insert file-a-contents)
+ (save-buffer)
+
+ ;; Verify that both files have equal contents
+ (should (equal nil (ediff-same-file-contents file-a file-b)))
+
+ (ssh-deploy-upload-handler)
+
+ ;; Verify that both files have equal contents
+ (should (equal t (ediff-same-file-contents file-a file-b)))
+
+ ;; Delete both test files
+ (delete-file file-b)
+ (delete-file file-a))
+
+ ;; (find-file) changes default-directory so we revert it here
+ (setq default-directory old-default-directory))))
+
(delete-directory directory-a t)
(delete-directory directory-b t)))
@@ -103,6 +185,7 @@
(ssh-deploy-test--get-revision-path)
(ssh-deploy-test--file-is-in-path)
(ssh-deploy-test--is-not-empty-string)
+ (ssh-deploy-test--upload)
(ssh-deploy-test--download))
(ssh-deploy-test)
- [elpa] externals/ssh-deploy 1073a7c 078/133: Replace more (require) with (autoload), (continued)
- [elpa] externals/ssh-deploy 1073a7c 078/133: Replace more (require) with (autoload), Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d992624 087/133: More work on asynchronous unit test of detecting remote changes, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 3223f69 094/133: Updated Travis file, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 9b5d3d2 111/133: Fixed bug wih conditonal logic for async file diff, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy bebeaa1 100/133: Updated version to 3.1, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy c4fd187 039/133: Deletion working from diff-mode, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 88300e3 043/133: Improved wording of remote change detection, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e08b8bb 044/133: Improved documentation, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy b480db9 055/133: Changed (when (not)) to (unless), Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 31cb94d 060/133: Added compile command to makefile and added a .gitignore file, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d03bd70 068/133: Added unit-test for uploads,
Stefan Monnier <=
- [elpa] externals/ssh-deploy 95e823a 074/133: Fixed issue with byte-compilation warning in new unit tests, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy f233e2e 075/133: Removed checks for ediff-same-file-contents function since it's built-in in Emacs, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 336833f 076/133: Got (autoload) working inside asynchronous process, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy db73e5b 083/133: Started in new function for detecting remote changes that should be testable by unit tests, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 3a6c3ac 084/133: More work on making detect remote changes unit-testable, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 7d578da 088/133: Passing unit test for asynchronous change detection, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 20a87ab 099/133: Added async.el to travis test, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 761eb11 098/133: Updated Travis to use emacs version snapshot, 25.1 and 26.1 via EVM, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 0111640 108/133: Removed unnecessary async autoloads, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy ea734f5 104/133: Added note, Stefan Monnier, 2021/03/27