aboutsummaryrefslogtreecommitdiffstats
path: root/test/sch/handle_test.clj
diff options
context:
space:
mode:
authorMichael Hwang <mhwang@research.att.com>2018-02-22 19:05:02 -0500
committerMichael Hwang <mhwang@research.att.com>2018-02-22 19:08:28 -0500
commit308a8f90cc66b033535aa4c5c2098bb5bfcb26ee (patch)
tree797e5caed087789bb24095e6a130a1e4d55f4c85 /test/sch/handle_test.clj
parentd914d08a70f018468e4b909a780c753ebce243e9 (diff)
Fix monkeypatching issue, use clj-fakes
Change-Id: I8ae31c1b3dfff3096e4bfef709a8f0581d2e9a7c Issue-ID: DCAEGEN2-260 Signed-off-by: Michael Hwang <mhwang@research.att.com>
Diffstat (limited to 'test/sch/handle_test.clj')
-rw-r--r--test/sch/handle_test.clj41
1 files changed, 23 insertions, 18 deletions
diff --git a/test/sch/handle_test.clj b/test/sch/handle_test.clj
index 3ff0618..e986563 100644
--- a/test/sch/handle_test.clj
+++ b/test/sch/handle_test.clj
@@ -21,7 +21,8 @@
(ns sch.handle-test
(:use (clojure test))
(:require [cheshire.core :refer [parse-stream]]
- [sch.handle :refer :all])
+ [sch.handle :refer :all]
+ [clj-fakes.core :as f])
)
@@ -45,10 +46,12 @@
service-type-requests [{:typeName "some-type" :asdcServiceId "abc"
:asdcResourceId "123" :typeVersion 3}]
fake-get-service-types-insert (partial fake-get-service-types {})
- nada (intern 'sch.inventory-client 'get-service-types! fake-get-service-types-insert)]
- (is (= service-type-requests (find-service-types-to-post "http://inventory"
- service-type-requests)))
- )))
+ ]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/get-service-types! fake-get-service-types-insert)
+ (is (= service-type-requests (find-service-types-to-post "http://inventory"
+ service-type-requests)))
+ ))))
(deftest test-post-service-types
@@ -56,11 +59,12 @@
(assoc request :typeId "123"))]
(let [service-type-requests [{:typeName "some-type" :asdcServiceId "abc"
:asdcResourceId "123" :typeVersion 3}]
- post-service-types #'sch.handle/post-service-types!
- nada (intern 'sch.inventory-client 'post-service-type! fake-post-service-type)]
- (is (= {:typeId "123" :typeName "some-type" :asdcServiceId "abc"
- :asdcResourceId "123" :typeVersion 3}
- (first (post-service-types "http://inventory" service-type-requests))))
+ post-service-types #'sch.handle/post-service-types!]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/post-service-type! fake-post-service-type)
+ (is (= {:typeId "123" :typeName "some-type" :asdcServiceId "abc"
+ :asdcResourceId "123" :typeVersion 3}
+ (first (post-service-types "http://inventory" service-type-requests)))))
)))
@@ -74,11 +78,11 @@
[{ :typeName "some-type"
:asdcServiceId "abc"
:asdcResourceId "456"
- :typeVersion 3 }])
- nada (intern 'sch.inventory-client 'get-service-types!
- fake-get-service-types-delete)]
- (is (= 1 (count (find-service-types-to-delete "http://inventory" "abc"
- service-type-requests))))
+ :typeVersion 3 }])]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/get-service-types! fake-get-service-types-delete)
+ (is (= 1 (count (find-service-types-to-delete "http://inventory" "abc"
+ service-type-requests)))))
)))
@@ -87,9 +91,10 @@
type-id)]
(let [service-type-requests [{:typeId "def" :typeName "some-type"
:asdcServiceId "abc" :asdcResourceId "123" :typeVersion 3}]
- delete-service-types #'sch.handle/delete-service-types!
- nada (intern 'sch.inventory-client 'delete-service-type! fake-delete-service-type)]
- (is (= "def" (first (delete-service-types "http://inventory" service-type-requests))))
+ delete-service-types #'sch.handle/delete-service-types!]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/delete-service-type! fake-delete-service-type)
+ (is (= "def" (first (delete-service-types "http://inventory" service-type-requests)))))
)))