aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml6
-rw-r--r--project.clj3
-rw-r--r--test/sch/core_test.clj9
-rw-r--r--test/sch/handle_test.clj41
-rw-r--r--test/sch/inventory_client_test.clj17
5 files changed, 48 insertions, 28 deletions
diff --git a/pom.xml b/pom.xml
index e40e352..bbabc27 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,6 +95,12 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<artifactId>clj-yaml</artifactId>
<version>0.4.0</version>
</dependency>
+ <dependency>
+ <groupId>clj-fakes</groupId>
+ <artifactId>clj-fakes</artifactId>
+ <version>0.9.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/project.clj b/project.clj
index 45976e5..3953da1 100644
--- a/project.clj
+++ b/project.clj
@@ -37,5 +37,8 @@
:repositories [["onap nexus" "https://nexus.onap.org/content/repositories/snapshots/"]]
:plugins [[lein-cloverage "1.0.9"]]
+ :profiles { :test { :dependencies [[clj-fakes "0.9.0"]] }
+ ; Added this for cloverage
+ :dev { :dependencies [[clj-fakes "0.9.0"]] } }
)
diff --git a/test/sch/core_test.clj b/test/sch/core_test.clj
index e441343..958a0e6 100644
--- a/test/sch/core_test.clj
+++ b/test/sch/core_test.clj
@@ -20,7 +20,8 @@
(ns sch.core-test
(:use (clojure test))
- (:require [sch.core :refer [create-distribution-client-config deploy-artifacts-ex!]])
+ (:require [sch.core :refer [create-distribution-client-config deploy-artifacts-ex!]]
+ [clj-fakes.core :as f])
(:import (org.openecomp.sdc.utils DistributionStatusEnum))
)
@@ -38,9 +39,11 @@
}]}]
requests [{:asdcResourceId "123" :typeName "type-foo"}]
deploy-artifacts (partial deploy-artifacts-echo requests [] [] [])
- nada (intern 'sch.handle 'deploy-artifacts! deploy-artifacts)
]
- (is (= nil (deploy-artifacts-ex! "http://inventory" service-metadata requests send-dist-status-only-ok)))
+ (f/with-fakes
+ (f/patch! #'sch.handle/deploy-artifacts! deploy-artifacts)
+ (is (= nil (deploy-artifacts-ex! "http://inventory" service-metadata requests
+ send-dist-status-only-ok))))
)))
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)))))
)))
diff --git a/test/sch/inventory_client_test.clj b/test/sch/inventory_client_test.clj
index 86f369c..493a186 100644
--- a/test/sch/inventory_client_test.clj
+++ b/test/sch/inventory_client_test.clj
@@ -21,7 +21,8 @@
(ns sch.inventory-client-test
(:use (clojure test))
(:require [sch.inventory-client :as ic]
- [cheshire.core :refer [generate-string]])
+ [cheshire.core :refer [generate-string]]
+ [clj-fakes.core :as f])
)
@@ -42,9 +43,10 @@
{:status 200 :body result})]
(let [results {:items [{:typeId "123"}]}
conn (ic/create-inventory-conn "http://inventory")
- fake-get-success (partial fake-get (generate-string results))
- nada (intern 'clj-http.client 'get fake-get-success)]
- (is (= (:items results) (ic/get-service-types! conn [])))
+ fake-get-success (partial fake-get (generate-string results))]
+ (f/with-fakes
+ (f/patch! #'clj-http.client/get fake-get-success)
+ (is (= (:items results) (ic/get-service-types! conn []))))
)))
@@ -53,7 +55,8 @@
{:status 200 :body result})]
(let [result {:typeId "123"}
conn (ic/create-inventory-conn "http://inventory")
- fake-post-success (partial fake-post (generate-string result))
- nada (intern 'clj-http.client 'post fake-post-success)]
- (is (= result (ic/post-service-type! conn {})))
+ fake-post-success (partial fake-post (generate-string result))]
+ (f/with-fakes
+ (f/patch! #'clj-http.client/post fake-post-success)
+ (is (= result (ic/post-service-type! conn {}))))
)))