blob: 90de58bf78abcdc58f484897772538d5103fbf4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
(ns chameleon.testing
(:require [clojure.test :as t]
[clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen]
[clojure.spec.test.alpha :as st]
[chameleon.logging :as log]
[chameleon.specs :as cs]
[chameleon.route :as cr]
[chameleon.aai-processor :as cai]
[chameleon.config :as cc]
[integrant.core :as ic]
[integrant.core :as ig]
[chameleon.aai-processor]))
;; STUBS
(s/fdef chameleon.route/assert-gallifrey!
:args (s/cat :host :chameleon.specs/host
:provenance :chameleon.specs/provenance
:type :chameleon.specs/type
:payload :chameleon.specs/payload
:loggers :chameleon.specs/loggers)
:ret nil?)
(s/fdef org.httpkit.client/request
:args (s/cat :host :chameleon.specs/host
:provenance :chameleon.specs/provenance
:type :chameleon.specs/type
:payload :chameleon.specs/payload
:loggers :chameleon.specs/loggers)
:ret (s/or :get :chameleon.specs/string
:create (s/spec clojure.string/blank? :gen #(gen/return ""))
:update :chameleon.specs/string))
(s/fdef ig/ref
:args (binding [s/*recursion-limit* 30]
(s/cat :keyword (s/spec keyword? :gen-max 4)))
:ret any?)
(s/fdef ig/load-namespaces
:args (binding [s/*recursion-limit* 30]
(s/cat :config (s/spec map? :gen-max 4)))
:ret map?)
(s/fdef org.httpkit.client/request
:args (s/cat :request map?)
:ret :route/response)
;; TESTS
;; This requires a fix. I should return a random generated hashmap and not an empty one.
;; If i leave it at `(s/spec map?)` it takes about 7 minutes
;; to run the tests, so returning an empty hash-map for now.
(s/fdef chameleon.config/config
:args (s/cat :config (s/spec map? :gen #(gen/return {})))
:ret map?)
(s/fdef chameleon.aai-processor/from-spike
:args (s/cat :gallifrey-host :chameleon.specs/host
:payload :spike/payload
:loggers :chameleon.specs/loggers)
:ret nil?)
(s/fdef chameleon.aai-processor/from-gallifrey
:args (s/cat :body :gallifrey/payload)
:ret map?)
(s/fdef chameleon.aai-processor/gen-trim-relationship
:args (s/cat :relationship :chameleon.specs/relationship)
:ret map?)
(s/fdef chameleon.kafka/clj-kafka-consumer
:args (s/cat :config :kafka/config :group-id :chameleon.specs/string
:topic :chameleon.specs/string :logger :chameleon.specs/logger)
:ret :kafka/consumer)
(s/fdef chameleon.kafka/consumer-record->clojure
:args (s/cat :consumer-record :kafka/consumer-record)
:ret :kafka/clojure-consumer-record)
(s/fdef chameleon.route/query
:args (s/cat :host :chameleon.specs/host :key :kafka/key :type :chameleon.specs/type
:gallifrey-params :gallifrey/payload)
:ret string?)
(s/fdef chameleon.route/assert-create!
:args (s/cat :host :chameleon.specs/host :actor :chameleon.specs/string
:type :chameleon.specs/type :key :kafka/key
:payload :gallifrey/payload)
:ret string?)
(s/fdef chameleon.route/assert-update!
:args (s/cat :host :chameleon.specs/host :actor :chameleon.specs/string
:type :chameleon.specs/type :key :kafka/key
:payload :gallifrey/payload)
:ret string?)
(s/fdef chameleon.route/assert-delete!
:args (s/cat :host :chameleon.specs/host :actor :chameleon.specs/string
:type :chameleon.specs/type :key :kafka/key
:payload :gallifrey/payload)
:ret string?)
;; INSTRUMENTS - MOCKS
(st/instrument 'chameleon.route/assert-gallifrey! {:stub '(chameleon.route/assert-gallifrey!)})
(st/instrument 'org.httpkit.client/request {:stub '(org.httpkit.client/request)})
(st/instrument 'ig/ref {:stub '(ig/ref)})
(st/instrument 'ig/load-namespaces {:stub '(ig/load-namespaces)})
;; TESTING INSTRUMENTATIONS
#_(chameleon.route/assert-gallifrey! "host" "aai" "type" {}
(log/error-logger "chameleon.testing") (log/audit-logger "chameleon.testing"))
#_(org.httpkit.client/request {"host" "aai"})
#_(integrant.core/load-namespaces {:foo "bar"})
#_(integrant.core/ref :foo)
(->> '(chameleon.config/config
chameleon.aai-processor/from-spike
chameleon.aai-processor/from-gallifrey
chameleon.aai-processor/gen-trim-relationship
chameleon.kafka/clj-kafka-consumer
chameleon.kafka/consumer-record->clojure
chameleon.route/query
chameleon.route/assert-create!
chameleon.route/assert-update!)
st/check
st/summarize-results)
|