Skip to content

Commit

Permalink
[t]: methods to frames tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deadtrickster committed Jan 15, 2016
1 parent 738b067 commit 5723020
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions cl-amqp.test.asd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
(:test-file "util/binary-string")
(:test-file "conditions")
(:test-file "frame")
(:test-file "method")
(:test-file "types"))))
:defsystem-depends-on (:prove-asdf)
:perform (test-op :after (op c)
Expand Down
53 changes: 53 additions & 0 deletions t/method.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
(in-package :cl-amqp.test)

(enable-binary-string-syntax)

(plan 1)

(subtest "Methods to/from frames"
(subtest "Methods to frames"
(subtest "Content method with content"
(let* ((method (make-instance 'amqp-method-basic-publish :exchange "qwe"
:content #b"Hello World!"))
(frames
(method-to-frames method 1 14)))
(is (length frames) 5 "Five frames")

(is-type (first frames) 'method-frame)
(is (frame-channel (first frames)) 1)
(is-type (second frames) 'header-frame)
(is (frame-channel (second frames)) 1)

(is-type (third frames) 'body-frame)
(is (frame-payload (third frames)) #b"Hello" :test #'equalp)
(is (frame-channel (third frames)) 1)

(is-type (fourth frames) 'body-frame)
(is (frame-payload (fourth frames)) #b" Worl" :test #'equalp)
(is (frame-channel (fourth frames)) 1)

(is-type (fifth frames) 'body-frame)
(is (frame-payload (fifth frames)) #b"d!" :test #'equalp)
(is (frame-channel (fifth frames)) 1)))

(subtest "Content method without content"
(let* ((method (make-instance 'amqp-method-basic-publish :exchange "qwe"))
(frames
(method-to-frames method 2 14)))
(is (length frames) 2 "Five frames")

(is-type (first frames) 'method-frame)
(is (frame-channel (first frames)) 2)
(is-type (second frames) 'header-frame)
(is (frame-channel (second frames)) 2)))

(subtest "Non-content method"
(let* ((method (make-instance 'amqp-method-queue-declare :queue "qwe"))
(frames
(method-to-frames method 2 14)))
(is (length frames) 1 "Single frame")

(is-type (first frames) 'method-frame)
(is (frame-channel (first frames)) 2)))))

(finalize)

0 comments on commit 5723020

Please sign in to comment.