@@ -124,8 +124,9 @@ var _ = Describe("API Gateway", func() {
124124 }
125125 actionHandlers = filterActions (ctx , settings , services )
126126 Expect (len (actionHandlers )).Should (Equal (2 ))
127- Expect (actionHandlers [0 ].pattern ()).Should (Equal ("/user/list" ))
128- Expect (actionHandlers [1 ].pattern ()).Should (Equal ("/user/update" ))
127+ patterns := actionHandlers [0 ].pattern () + " " + actionHandlers [1 ].pattern ()
128+ Expect (patterns ).Should (ContainSubstring ("/user/list" ))
129+ Expect (patterns ).Should (ContainSubstring ("/user/update" ))
129130 })
130131
131132 It ("should handle multiple routes" , func () {
@@ -181,7 +182,7 @@ var _ = Describe("API Gateway", func() {
181182 "nilvalue" : nil ,
182183 }
183184
184- response := & mockReponseWriter {}
185+ response := & mockReponseWriter {header : map [ string ][] string {} }
185186 ah := actionHandler {}
186187 ah .sendReponse (log .WithField ("test" , "" ), payload .New (result ), response )
187188 json := response .String ()
@@ -190,15 +191,17 @@ var _ = Describe("API Gateway", func() {
190191 Expect (gjson .Get (json , "name" ).String ()).Should (Equal ("John" ))
191192
192193 Expect (response .statusCode ).Should (Equal (succesStatusCode ))
194+ Expect (response .Header ().Get ("Content-Type" )).Should (Equal ("application/json" ))
193195 })
194196
195197 It ("should convert error result into JSON and send in the reponse with error status code" , func () {
196- response := & mockReponseWriter {}
198+ response := & mockReponseWriter {header : map [ string ][] string {} }
197199 ah := actionHandler {}
198200 ah .sendReponse (log .WithField ("test" , "" ), payload .New (errors .New ("Some error..." )), response )
199201 json := response .String ()
200202 Expect (gjson .Get (json , "error" ).String ()).Should (Equal ("Some error..." ))
201203 Expect (response .statusCode ).Should (Equal (errorStatusCode ))
204+ Expect (response .Header ().Get ("Content-Type" )).Should (Equal ("application/json" ))
202205 })
203206 })
204207
0 commit comments