@@ -38,10 +38,7 @@ var _ = Describe("/sources", Ordered, func() {
3838 Context ("POST" , func () {
3939 It ("creates a source" , func () {
4040 resp , err := adminClient .R ().
41- SetBody (map [string ]interface {}{
42- "path" : "/v1" ,
43- "methods" : []string {"POST" },
44- }).
41+ SetBody (`{ "type": "http", "config": { "http": { "path": "" } }}` ).
4542 SetResult (entities.Source {}).
4643 Post ("/workspaces/default/sources" )
4744 assert .Nil (GinkgoT (), err )
@@ -51,10 +48,10 @@ var _ = Describe("/sources", Ordered, func() {
5148 result := resp .Result ().(* entities.Source )
5249 assert .NotNil (GinkgoT (), result .ID )
5350 assert .Equal (GinkgoT (), true , result .Enabled )
54- assert .Equal (GinkgoT (), "/v1" , result .Path )
55- assert .EqualValues (GinkgoT (), []string {"POST" }, result .Methods )
51+ assert .True (GinkgoT (), len ( result .Config . HTTP . Path ) > 0 ) // auto generate path
52+ assert .EqualValues (GinkgoT (), []string {"POST" }, result .Config . HTTP . Methods )
5653 assert .Equal (GinkgoT (), false , result .Async )
57- assert .True (GinkgoT (), nil == result .Response )
54+ assert .True (GinkgoT (), nil == result .Config . HTTP . Response )
5855
5956 e , err := db .Sources .Get (context .TODO (), result .ID )
6057 assert .Nil (GinkgoT (), err )
@@ -70,7 +67,7 @@ var _ = Describe("/sources", Ordered, func() {
7067 assert .Nil (GinkgoT (), err )
7168 assert .Equal (GinkgoT (), 400 , resp .StatusCode ())
7269 assert .Equal (GinkgoT (),
73- `{"message":"Request Validation","error":{"message":"request validation","fields":{"methods":"required field missing","path ":"required field missing"}}}` ,
70+ `{"message":"Request Validation","error":{"message":"request validation","fields":{"config ":"required field missing"}}}` ,
7471 string (resp .Body ()))
7572 })
7673 })
@@ -166,14 +163,19 @@ var _ = Describe("/sources", Ordered, func() {
166163 It ("updates by id" , func () {
167164 resp , err := adminClient .R ().
168165 SetBody (map [string ]interface {}{
169- "path" : "/v1" ,
170- "methods" : []string {"GET" , "POST" , "PUT" , "DELETE" },
171- "async" : true ,
172- "response" : map [string ]interface {}{
173- "code" : 200 ,
174- "content_type" : "text/plain" ,
175- "body" : "OK" ,
166+ "type" : "http" ,
167+ "config" : map [string ]interface {}{
168+ "http" : map [string ]interface {}{
169+ "path" : "/v1" ,
170+ "methods" : []string {"GET" , "POST" , "PUT" , "DELETE" },
171+ "response" : map [string ]interface {}{
172+ "code" : 200 ,
173+ "content_type" : "text/plain" ,
174+ "body" : "OK" ,
175+ },
176+ },
176177 },
178+ "async" : true ,
177179 }).
178180 SetResult (entities.Source {}).
179181 Put ("/workspaces/default/sources/" + entity .ID )
@@ -183,14 +185,14 @@ var _ = Describe("/sources", Ordered, func() {
183185 result := resp .Result ().(* entities.Source )
184186
185187 assert .Equal (GinkgoT (), entity .ID , result .ID )
186- assert .Equal (GinkgoT (), "/v1" , result .Path )
187- assert .EqualValues (GinkgoT (), []string {"GET" , "POST" , "PUT" , "DELETE" }, result .Methods )
188+ assert .Equal (GinkgoT (), "/v1" , result .Config . HTTP . Path )
189+ assert .EqualValues (GinkgoT (), []string {"GET" , "POST" , "PUT" , "DELETE" }, result .Config . HTTP . Methods )
188190 assert .Equal (GinkgoT (), true , result .Async )
189191 assert .EqualValues (GinkgoT (), & entities.CustomResponse {
190192 Code : 200 ,
191193 ContentType : "text/plain" ,
192194 Body : "OK" ,
193- }, result .Response )
195+ }, result .Config . HTTP . Response )
194196 })
195197 })
196198
0 commit comments