@@ -148,6 +148,7 @@ func TestApp_AddKafka_Patching(t *testing.T) {
148148 testcases := []struct {
149149 name string
150150 configs []* dynamic.Config
151+ reader dynamic.Reader
151152 test func (t * testing.T , app * runtime.App )
152153 }{
153154 {
@@ -244,12 +245,86 @@ func TestApp_AddKafka_Patching(t *testing.T) {
244245 require .Equal (t , "patch" , msg .Value .Summary )
245246 },
246247 },
248+ {
249+ name : "using relative file path" ,
250+ reader : & dynamictest.Reader {
251+ Data : map [string ]* dynamic.Config {
252+ "bar.yaml" : {
253+ Data : & asyncapi3.MessageRef {
254+ Value : asyncapi3test .NewMessage (
255+ asyncapi3test .WithMessageTitle ("original" ),
256+ ),
257+ },
258+ },
259+ },
260+ },
261+ configs : []* dynamic.Config {
262+ getConfig ("https://a.io/a" , asyncapi3test .NewConfig (
263+ asyncapi3test .WithInfo ("foo" , "foo" , "" ),
264+ asyncapi3test .WithChannel ("bar" ,
265+ asyncapi3test .UseMessage ("bar" ,
266+ & asyncapi3.MessageRef {Reference : dynamic.Reference {Ref : "bar.yaml" }},
267+ ),
268+ ),
269+ )),
270+ getConfig ("https://mokapi.io/b" , asyncapi3test .NewConfig (
271+ asyncapi3test .WithInfo ("foo" , "bar" , "" ),
272+ )),
273+ },
274+ test : func (t * testing.T , app * runtime.App ) {
275+ info := app .Kafka .Get ("foo" )
276+ ch := info .Channels ["bar" ]
277+ require .NotNil (t , ch )
278+ msg := ch .Value .Messages ["bar" ]
279+ require .NotNil (t , msg )
280+ require .Equal (t , "original" , msg .Value .Title )
281+ },
282+ },
283+ {
284+ name : "using relative u path" ,
285+ reader : & dynamictest.Reader {
286+ Data : map [string ]* dynamic.Config {
287+ "bar.yaml" : {
288+ Data : & asyncapi3.MessageRef {
289+ Value : asyncapi3test .NewMessage (
290+ asyncapi3test .WithMessageTitle ("original" ),
291+ ),
292+ },
293+ },
294+ },
295+ },
296+ configs : []* dynamic.Config {
297+ getConfig ("https://a.io/a" , asyncapi3test .NewConfig (
298+ asyncapi3test .WithInfo ("foo" , "foo" , "" ),
299+ asyncapi3test .WithChannel ("bar" ,
300+ asyncapi3test .UseMessage ("bar" ,
301+ & asyncapi3.MessageRef {Reference : dynamic.Reference {Ref : "bar.yaml" }},
302+ ),
303+ ),
304+ )),
305+ getConfig ("https://mokapi.io/b" , asyncapi3test .NewConfig (
306+ asyncapi3test .WithInfo ("foo" , "bar" , "" ),
307+ )),
308+ },
309+ test : func (t * testing.T , app * runtime.App ) {
310+ info := app .Kafka .Get ("foo" )
311+ ch := info .Channels ["bar" ]
312+ require .NotNil (t , ch )
313+ msg := ch .Value .Messages ["bar" ]
314+ require .NotNil (t , msg )
315+ require .Equal (t , "original" , msg .Value .Title )
316+ },
317+ },
247318 }
248319 for _ , tc := range testcases {
249320 tc := tc
250321 t .Run (tc .name , func (t * testing.T ) {
322+ r := tc .reader
323+ if r == nil {
324+ r = & dynamictest.Reader {}
325+ }
251326 cfg := & static.Config {}
252- app := runtime .New (cfg , & dynamictest. Reader {} )
327+ app := runtime .New (cfg , r )
253328 for _ , c := range tc .configs {
254329 _ , err := app .Kafka .Add (c , enginetest .NewEngine ())
255330 require .NoError (t , err )
0 commit comments