* test/automated/package-x-test.el: Do not mess with load-path.
[bpt/emacs.git] / test / automated / package-x-test.el
1 ;;; package-test.el --- Tests for the Emacs package system
2
3 ;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
4
5 ;; Author: Daniel Hackney <dan@haxney.org>
6 ;; Version: 1.0
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 (require 'package-x)
28 (require 'ert)
29 (require 'cl-lib)
30 (require 'package-test)
31
32 (defvar package-x-test--single-archive-entry-1-3
33 (cons 'simple-single
34 (package-make-ac-desc '(1 3) nil
35 "A single-file package with no dependencies"
36 'single
37 '((:url . "http://doodles.au"))))
38 "Expected contents of the archive entry from the \"simple-single\" package.")
39
40 (defvar package-x-test--single-archive-entry-1-4
41 (cons 'simple-single
42 (package-make-ac-desc '(1 4) nil
43 "A single-file package with no dependencies"
44 'single
45 nil))
46 "Expected contents of the archive entry from the updated \"simple-single\" package.")
47
48 (ert-deftest package-x-test-upload-buffer ()
49 "Test creating an \"archive-contents\" file"
50 (with-package-test (:basedir "data/package"
51 :file "simple-single-1.3.el"
52 :upload-base t)
53 (package-upload-buffer)
54 (should (file-exists-p (expand-file-name "archive-contents"
55 package-archive-upload-base)))
56 (should (file-exists-p (expand-file-name "simple-single-1.3.el"
57 package-archive-upload-base)))
58 (should (file-exists-p (expand-file-name "simple-single-readme.txt"
59 package-archive-upload-base)))
60
61 (let (archive-contents)
62 (with-temp-buffer
63 (insert-file-contents
64 (expand-file-name "archive-contents"
65 package-archive-upload-base))
66 (setq archive-contents
67 (package-read-from-string
68 (buffer-substring (point-min) (point-max)))))
69 (should (equal archive-contents
70 (list 1 package-x-test--single-archive-entry-1-3))))))
71
72 (ert-deftest package-x-test-upload-new-version ()
73 "Test uploading a new version of a package"
74 (with-package-test (:basedir "data/package"
75 :file "simple-single-1.3.el"
76 :upload-base t)
77 (package-upload-buffer)
78 (with-temp-buffer
79 (insert-file-contents "newer-versions/simple-single-1.4.el")
80 (package-upload-buffer))
81
82 (let (archive-contents)
83 (with-temp-buffer
84 (insert-file-contents
85 (expand-file-name "archive-contents"
86 package-archive-upload-base))
87 (setq archive-contents
88 (package-read-from-string
89 (buffer-substring (point-min) (point-max)))))
90 (should (equal archive-contents
91 (list 1 package-x-test--single-archive-entry-1-4))))))
92
93 (provide 'package-x-test)
94
95 ;;; package-x-test.el ends here