Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix test error

  • Loading branch information...
commit 141ba840200876a238255f07960c816a3e45230a 1 parent 02a9c8b
@sunng87 authored
Showing with 16 additions and 10 deletions.
  1. +1 −1  src/slacker/server/http.clj
  2. +15 −9 test/slacker/test/server/http.clj
View
2  src/slacker/server/http.clj
@@ -43,7 +43,7 @@
:body "rejected by access control list"}
;; normal response packet
(let [[ct code result] (second resp-body)
- content-type (str "application/" (str ct))
+ content-type (str "application/" (name ct))
status (case code
:success 200
:exception 500
View
24 test/slacker/test/server/http.clj
@@ -1,12 +1,11 @@
(ns slacker.test.server.http
(:use clojure.test)
+ (:use [slacker.common :only [version]] )
(:use slacker.server.http)
+ (:use slacker.serialization)
(:require [clojure.java.io :as io])
(:import [java.io ByteArrayOutputStream]))
-(defn fake-server-handler [req]
- (assoc req :code :success :result (:data req)))
-
(defn make-fake-data-stream [string-data]
(io/input-stream (.getBytes string-data "UTF-8")))
@@ -15,13 +14,20 @@
(io/copy bis bos)
(String. (.toByteArray bos) "UTF-8")))
-(deftest test-http
- (let [handler (wrap-http-server-handler fake-server-handler)
- in-data "[27 89]"
+(deftest test-http-request
+ (let [in-data "[27 89]"
req {:uri "/echo.clj" :body (make-fake-data-stream in-data)}
- resp (handler req)]
+ sreq (ring-req->slacker-req req)]
+ (is (= version (first sreq)))
+ (is (= :type-request (-> sreq (nth 2) first)))
+ (is (= :clj (-> sreq (nth 2) second first)))
+ (is (= "echo" (-> sreq (nth 2) second second)))))
+
+(deftest test-http-response
+ (let [result (serialize :clj [1])
+ sresp [version 0 [:type-response [:clj :success result]]]
+ resp (slacker-resp->ring-resp sresp)]
(is (= 200 (:status resp)))
- (is (= in-data (byteins->string (:body resp))))
- (is (= "application/clj" (get (:headers resp) "content-type")))))
+ (is (= "application/clj" (-> resp :headers (get "content-type"))))))
Please sign in to comment.
Something went wrong with that request. Please try again.