Commits

evhan committed 3aa4072

revparse tests

  • Participants
  • Parent commits 3508555

Comments (0)

Files changed (1)

      files
      content)))
 
+(test-group "revision parsing"
+  (let ((revparse
+         (lambda (s)
+           (receive (parse-revision-specification repo s)))))
+    (test "revparse with invalid revision" '(#f #f) (revparse "foo"))
+    (test "revparse with invalid revisions" '(#f #f) (revparse "foo..bar"))
+    (let ((revspec (revparse "HEAD")))
+      (test-assert "revparse with HEAD (1st value)"
+                   (object=? (car (commits repo sort: 'rev))
+                             (car (revparse "HEAD"))))
+      (test-assert "revparse with HEAD (2nd value)"
+                   (not (cadr (revparse "HEAD")))))
+    (let ((revspec (revparse (oid->string (commit-id commit)))))
+      (test-assert "revparse with sha1 (1st value)"
+                   (object=? commit (car revspec)))
+      (test-assert "revparse with sha1 (2nd value)"
+                   (not (cadr revspec))))
+    (let ((revspec (revparse (string-append
+                              (oid->string (commit-id commit))
+                              ".."
+                              (oid->string (commit-id (commit-parent commit)))))))
+      (test-assert "revparse with sha1 range (1st value)"
+                   (object=? commit (car revspec)))
+      (test-assert "revparse with sha1 range (2nd value)"
+                   (object=? (commit-parent commit) (cadr revspec))))))
+
 (test-group "generic object lookup"
   (test "repository-ref on nonexistent sha" #f (repository-ref repo sha1))
   (test "repository-ref on nonexistent oid" #f (repository-ref repo (string->oid sha1)))