44 "encoding/json"
55 "mokapi/api"
66 "mokapi/config/dynamic"
7+ "mokapi/config/dynamic/asyncApi"
78 "mokapi/config/dynamic/dynamictest"
89 "mokapi/config/static"
910 "mokapi/engine/enginetest"
@@ -57,7 +58,7 @@ func TestHandler_Kafka(t *testing.T) {
5758 {
5859 name : "get kafka services" ,
5960 app : func () * runtime.App {
60- app := runtime .New (& static.Config {})
61+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
6162 _ , _ = app .Kafka .Add (& dynamic.Config {
6263 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
6364 Data : asyncapi3test .NewConfig (
@@ -91,7 +92,7 @@ func TestHandler_Kafka(t *testing.T) {
9192 {
9293 name : "get specific" ,
9394 app : func () * runtime.App {
94- app := runtime .New (& static.Config {})
95+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
9596 cfg := & dynamic.Config {
9697 Info : dynamictest .NewConfigInfo (),
9798 Data : asyncapi3test .NewConfig (
@@ -221,7 +222,7 @@ func TestHandler_Kafka(t *testing.T) {
221222 {
222223 name : "get specific with group" ,
223224 app : func () * runtime.App {
224- app := runtime .New (& static.Config {})
225+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
225226 app .Kafka .Set ("foo" , getKafkaInfoWithGroup (asyncapi3test .NewConfig (
226227 asyncapi3test .WithInfo ("foo" , "bar" , "1.0" ),
227228 asyncapi3test .WithServer ("foo" , "kafka" , "foo.bar" ),
@@ -246,7 +247,7 @@ func TestHandler_Kafka(t *testing.T) {
246247 {
247248 name : "get specific with group no generation" ,
248249 app : func () * runtime.App {
249- app := runtime .New (& static.Config {})
250+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
250251 app .Kafka .Set ("foo" , getKafkaInfoWithGroup (asyncapi3test .NewConfig (
251252 asyncapi3test .WithInfo ("foo" , "bar" , "1.0" ),
252253 asyncapi3test .WithServer ("foo" , "kafka" , "foo.bar" ),
@@ -273,7 +274,7 @@ func TestHandler_Kafka(t *testing.T) {
273274 return t1
274275 }
275276
276- app := runtime .New (& static.Config {})
277+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
277278 app .Kafka .Set ("foo" , getKafkaInfoWithGroup (asyncapi3test .NewConfig (
278279 asyncapi3test .WithInfo ("foo" , "bar" , "1.0" ),
279280 asyncapi3test .WithServer ("foo" , "kafka" , "foo.bar" ),
@@ -321,7 +322,7 @@ func TestHandler_Kafka(t *testing.T) {
321322 {
322323 name : "get specific with topic and openapi schema" ,
323324 app : func () * runtime.App {
324- app := runtime .New (& static.Config {})
325+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
325326 app .Kafka .Set ("foo" , getKafkaInfo (asyncapi3test .NewConfig (
326327 asyncapi3test .WithInfo ("foo" , "bar" , "1.0" ),
327328 asyncapi3test .WithChannel ("foo" ,
@@ -369,7 +370,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
369370 {
370371 name : "get kafka topics but empty" ,
371372 app : func () * runtime.App {
372- app := runtime .New (& static.Config {})
373+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
373374 _ , _ = app .Kafka .Add (& dynamic.Config {
374375 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
375376 Data : asyncapi3test .NewConfig (
@@ -394,7 +395,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
394395 {
395396 name : "get kafka topics with one topic" ,
396397 app : func () * runtime.App {
397- app := runtime .New (& static.Config {})
398+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
398399 _ , _ = app .Kafka .Add (& dynamic.Config {
399400 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
400401 Data : asyncapi3test .NewConfig (
@@ -424,7 +425,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
424425 {
425426 name : "get specific kafka topic" ,
426427 app : func () * runtime.App {
427- app := runtime .New (& static.Config {})
428+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
428429 _ , _ = app .Kafka .Add (& dynamic.Config {
429430 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
430431 Data : asyncapi3test .NewConfig (
@@ -454,7 +455,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
454455 {
455456 name : "get specific kafka topic but not found" ,
456457 app : func () * runtime.App {
457- app := runtime .New (& static.Config {})
458+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
458459 _ , _ = app .Kafka .Add (& dynamic.Config {
459460 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
460461 Data : asyncapi3test .NewConfig (
@@ -482,7 +483,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
482483 {
483484 name : "produce kafka message into topic" ,
484485 app : func () * runtime.App {
485- app := runtime .New (& static.Config {})
486+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
486487
487488 msg := asyncapi3test .NewMessage (
488489 asyncapi3test .WithContentType ("application/json" ),
@@ -532,7 +533,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
532533 {
533534 name : "produce kafka message into topic using binary" ,
534535 app : func () * runtime.App {
535- app := runtime .New (& static.Config {})
536+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
536537 _ , _ = app .Kafka .Add (& dynamic.Config {
537538 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
538539 Data : asyncapi3test .NewConfig (
@@ -571,7 +572,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
571572 {
572573 name : "produce invalid kafka message into topic" ,
573574 app : func () * runtime.App {
574- app := runtime .New (& static.Config {})
575+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
575576
576577 msg := asyncapi3test .NewMessage (
577578 asyncapi3test .WithContentType ("application/json" ),
@@ -627,7 +628,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
627628 {
628629 name : "get kafka partitions" ,
629630 app : func () * runtime.App {
630- app := runtime .New (& static.Config {})
631+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
631632 _ , _ = app .Kafka .Add (& dynamic.Config {
632633 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
633634 Data : asyncapi3test .NewConfig (
@@ -656,7 +657,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
656657 {
657658 name : "get specific kafka partition" ,
658659 app : func () * runtime.App {
659- app := runtime .New (& static.Config {})
660+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
660661 _ , _ = app .Kafka .Add (& dynamic.Config {
661662 Info : dynamic.ConfigInfo {Url : try .MustUrl ("kafka.yaml" )},
662663 Data : asyncapi3test .NewConfig (
@@ -685,7 +686,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
685686 {
686687 name : "produce kafka message into specific partition" ,
687688 app : func () * runtime.App {
688- app := runtime .New (& static.Config {})
689+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
689690
690691 msg := asyncapi3test .NewMessage (
691692 asyncapi3test .WithContentType ("application/json" ),
@@ -739,7 +740,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
739740 {
740741 name : "produce kafka message into specific partition using XML" ,
741742 app : func () * runtime.App {
742- app := runtime .New (& static.Config {})
743+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
743744
744745 msg := asyncapi3test .NewMessage (
745746 asyncapi3test .WithContentType ("application/xml" ),
@@ -801,7 +802,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
801802 {
802803 name : "produce kafka message into specific partition using plain XML string" ,
803804 app : func () * runtime.App {
804- app := runtime .New (& static.Config {})
805+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
805806
806807 msg := asyncapi3test .NewMessage (
807808 asyncapi3test .WithContentType ("application/xml" ),
@@ -853,7 +854,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
853854 {
854855 name : "produce invalid kafka message into specific partition using plain XML string" ,
855856 app : func () * runtime.App {
856- app := runtime .New (& static.Config {})
857+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
857858
858859 msg := asyncapi3test .NewMessage (
859860 asyncapi3test .WithContentType ("application/xml" ),
@@ -912,7 +913,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
912913 {
913914 name : "get records" ,
914915 app : func () * runtime.App {
915- app := runtime .New (& static.Config {})
916+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
916917
917918 msg := asyncapi3test .NewMessage (
918919 asyncapi3test .WithContentType ("application/json" ),
@@ -970,7 +971,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
970971 {
971972 name : "get specific record" ,
972973 app : func () * runtime.App {
973- app := runtime .New (& static.Config {})
974+ app := runtime .New (& static.Config {}, & dynamictest. Reader {} )
974975
975976 msg := asyncapi3test .NewMessage (
976977 asyncapi3test .WithContentType ("application/json" ),
@@ -1035,7 +1036,7 @@ func TestHandler_KafkaAPI(t *testing.T) {
10351036}
10361037
10371038func TestHandler_Kafka_NotFound (t * testing.T ) {
1038- h := api .New (runtime .New (& static.Config {}), static.Api {})
1039+ h := api .New (runtime .New (& static.Config {}, & dynamictest. Reader {} ), static.Api {})
10391040
10401041 try .Handler (t ,
10411042 http .MethodGet ,
@@ -1096,6 +1097,13 @@ func TestHandler_Kafka_Metrics(t *testing.T) {
10961097 }
10971098}
10981099
1100+ func Test_IsAsyncApiConfig (t * testing.T ) {
1101+ v2 := & asyncApi.Config {Info : asyncApi.Info {Name : "foo" }}
1102+ _ , ok := runtime .IsAsyncApiConfig (& dynamic.Config {Data : v2 })
1103+ require .True (t , ok )
1104+
1105+ }
1106+
10991107func getKafkaInfo (config * asyncapi3.Config ) * runtime.KafkaInfo {
11001108 return & runtime.KafkaInfo {
11011109 Config : config ,
0 commit comments