Browse code
feat: add initial test
Ed L authored on 15/11/2020 19:31:05
Showing 6 changed files
Showing 6 changed files
... | ... |
@@ -29,11 +29,11 @@ |
29 | 29 |
(get-local-packed-branches root))) |
30 | 30 |
|
31 | 31 |
(defgeneric branches (repository) |
32 |
- (:method ((repository repository)) |
|
32 |
+ (:method ((repository git-repository)) |
|
33 | 33 |
(get-local-branches (root repository)))) |
34 | 34 |
|
35 | 35 |
(defgeneric branch (repository name) |
36 |
- (:method ((repository repository) name) |
|
36 |
+ (:method ((repository git-repository) name) |
|
37 | 37 |
(second |
38 | 38 |
(find name (get-local-branches (root repository)) |
39 | 39 |
:test 'equal |
... | ... |
@@ -34,3 +34,14 @@ |
34 | 34 |
|
35 | 35 |
;; stable programmer interface |
36 | 36 |
(:file "porcelain" :depends-on ("package" "git" "commit")))) |
37 |
+(defsystem :cl-git/tests |
|
38 |
+ :description "" |
|
39 |
+ :author "Ed L <edward@elangley.org>" |
|
40 |
+ :license "MIT" |
|
41 |
+ :depends-on (#:alexandria |
|
42 |
+ #:uiop |
|
43 |
+ #:serapeum |
|
44 |
+ #:fiveam |
|
45 |
+ #:cl-git) |
|
46 |
+ :serial t |
|
47 |
+ :components ()) |
... | ... |
@@ -3,7 +3,8 @@ |
3 | 3 |
(defpackage :fwoar.cl-git |
4 | 4 |
(:use :cl ) |
5 | 5 |
(:export |
6 |
- #:ensure-ref)) |
|
6 |
+ #:ensure-ref |
|
7 |
+ #:repository)) |
|
7 | 8 |
|
8 | 9 |
(defpackage :cl-git-user |
9 | 10 |
(:use :cl :fwoar.cl-git)) |
... | ... |
@@ -13,4 +14,4 @@ |
13 | 14 |
(:export #:show #:branch #:branches #:commit-parents #:in-repository |
14 | 15 |
#:with-repository #:current-repository #:show-repository #:git |
15 | 16 |
#:tree #:contents #:component |
16 |
- #:rev-list)) |
|
17 |
+ #:rev-list #:repository)) |
36 | 33 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,36 @@ |
1 |
+(defpackage :fwoar.cl-git.branch-resolution |
|
2 |
+ (:use :cl ) |
|
3 |
+ (:export )) |
|
4 |
+(in-package :fwoar.cl-git.branch-resolution) |
|
5 |
+ |
|
6 |
+(defclass fake-repository (fwoar.cl-git::repository) |
|
7 |
+ ()) |
|
8 |
+(defclass fake-ref () |
|
9 |
+ ((%repository :initarg :repository :reader repository) |
|
10 |
+ (%id :initarg :id :reader id))) |
|
11 |
+ |
|
12 |
+(defparameter *expected-branches* |
|
13 |
+ '(("master" "ref1") |
|
14 |
+ ("other" "ref2"))) |
|
15 |
+ |
|
16 |
+(defmethod fwoar.cl-git::repository ((object symbol)) |
|
17 |
+ (fwoar.cl-git::resolve-repository object)) |
|
18 |
+(defmethod fwoar.cl-git::resolve-repository fwoar.cl-git::alts :branch-resolution |
|
19 |
+ ((o (eql :branch-resolution))) |
|
20 |
+ (make-instance 'fake-repository :root "the-root")) |
|
21 |
+(defmethod fwoar.cl-git::branches ((repository fake-repository)) |
|
22 |
+ *expected-branches*) |
|
23 |
+(defmethod fwoar.cl-git::ref ((repository fake-repository) id) |
|
24 |
+ (fw.lu:new 'fake-ref repository id)) |
|
25 |
+ |
|
26 |
+(fiveam:def-suite :fwoar.cl-git.branch-resolution |
|
27 |
+ :description "testing branch resolution") |
|
28 |
+(fiveam:in-suite :fwoar.cl-git.branch-resolution) |
|
29 |
+ |
|
30 |
+(fiveam:def-test simple () |
|
31 |
+ (5am:is (typep (git:with-repository (:branch-resolution) |
|
32 |
+ (git:repository)) |
|
33 |
+ 'fake-repository)) |
|
34 |
+ (5am:is (equal (git:with-repository (:branch-resolution) |
|
35 |
+ (git:git (branches))) |
|
36 |
+ *expected-branches*))) |