PageRenderTime 122ms CodeModel.GetById 70ms app.highlight 3ms RepoModel.GetById 47ms app.codeStats 0ms

/test/core/request-adapter.lisp

http://github.com/skypher/cl-oauth
Lisp | 43 lines | 34 code | 6 blank | 3 comment | 0 complexity | 68b1f0cf1bd4d332dd6d25ebf796312b MD5 | raw file
 1
 2(in-package :oauth-test)
 3
 4(defvar *request-object* nil)
 5(defvar *request-method* :get)
 6(defvar *request-uri* "http://host.domain/path")
 7(defvar *auth-parameters* nil)
 8(defvar *post-parameters* nil)
 9(defvar *get-parameters* nil)
10
11(defun make-test-request-adapter ()
12  (make-request-adapter :request-object-fn (lambda ()
13                                             ;; prevent caching.
14                                             ;; TODO: use private caches for testing
15                                             ;; so we don't interfere with live data.
16                                             (or *request-object* (random most-positive-fixnum)))
17                        :request-method-fn (lambda (request)
18                                             (declare (ignore request))
19                                             *request-method*)
20                        :request-uri-fn (lambda (request)
21                                          (declare (ignore request))
22                                          *request-uri*)
23                        :auth-parameters-fn (lambda (request)
24                                              (declare (ignore request))
25                                              *auth-parameters*)
26                        :post-parameters-fn  (lambda (request)
27                                              (declare (ignore request))
28                                              *post-parameters*)
29                        :get-parameters-fn (lambda (request)
30                                              (declare (ignore request))
31                                              *get-parameters*)))
32
33(defun init-test-request-adapter ()
34  (setf *request-adapter* (make-test-request-adapter)))
35
36(defmethod asdf:perform ((o asdf:test-op) (c (eql (asdf:find-system :cl-oauth))))
37  (let ((original-request-adapter *request-adapter*))
38    (unwind-protect 
39        (progn
40          (init-test-request-adapter)
41          (fiveam:run! 'oauth))
42      (setf *request-adapter* original-request-adapter))))
43