11% % @doc Tests for IDL converter / loader
22% % @end
3- % % @author Sergey Prokhhorov <me@seriyps.ru>
3+ % % @author Sergey Prokhorov <me@seriyps.ru>
44-module (avro_idl_tests ).
55
66-include (" ../src/idl.hrl" ).
@@ -34,7 +34,7 @@ annotations_avpr_test() ->
3434 <<" namespace" >> => <<" enums" >>,
3535 <<" type" >> => ? AVRO_ENUM ,
3636 <<" name" >> => <<" MyEnum" >>,
37- <<" variants " >> => [<<" A" >>, <<" B" >>, <<" C" >>]},
37+ <<" symbols " >> => [<<" A" >>, <<" B" >>, <<" C" >>]},
3838 #{<<" doc" >> => <<" My Fixed" >>,
3939 <<" namespace" >> => <<" fixeds" >>,
4040 <<" type" >> => ? AVRO_FIXED ,
@@ -88,7 +88,7 @@ protocol_with_typedefs_avpr_test() ->
8888 [#{<<" name" >> := <<" MyEnum1" >>},
8989 #{<<" name" >> := <<" MyEnum2" >>,
9090 <<" type" >> := ? AVRO_ENUM ,
91- <<" variants " >> := [<<" VAR21" >>, <<" VAR22" >>, <<" VAR23" >>]},
91+ <<" symbols " >> := [<<" VAR21" >>, <<" VAR22" >>, <<" VAR23" >>]},
9292 #{<<" name" >> := <<" MyFix" >>,
9393 <<" type" >> := ? AVRO_FIXED ,
9494 <<" size" >> := 10 },
@@ -137,14 +137,14 @@ protocol_with_typedefs_avpr_test() ->
137137 Messages ).
138138
139139
140- duplicate_annotation_test () ->
140+ duplicate_annotation_avpr_test () ->
141141 ? assertError (
142142 {duplicate_annotation , " my_decorator" , _ , _ },
143143 avro_idl :str_to_avpr (
144144 " @my_decorator(\" a\" ) @my_decorator(\" b\" ) protocol MyProto{}" , " " )
145145 ).
146146
147- nested_complex_types_test () ->
147+ nested_complex_types_avr_test () ->
148148 ? assertEqual (
149149 #{<<" protocol" >> => <<" P" >>,
150150 <<" messages" >> => [],
@@ -165,9 +165,19 @@ nested_complex_types_test() ->
165165 " protocol P { record R { array<map<union{null, ns.T}>> f; }}" , " " )
166166 ).
167167
168+ full_protocol_load_test () ->
169+ Schema = read_schema (" full_protocol" ),
170+ DecSchema = avro_idl :decode_schema (Schema , " " ),
171+ _EncSchema = avro :encode_schema (DecSchema ).
172+ % % ?debugFmt("~n~p~n~s", [DecSchema, EncSchema]).
173+
168174% % Helpers
169175
170- idl_to_avpr (Name ) ->
176+ read_schema (Name ) ->
171177 File = " test/data/" ++ Name ++ " .avdl" ,
172178 {ok , B } = file :read_file (File ),
173- avro_idl :str_to_avpr (binary_to_list (B ), " " ).
179+ binary_to_list (B ).
180+
181+ idl_to_avpr (Name ) ->
182+ Schema = read_schema (Name ),
183+ avro_idl :str_to_avpr (Schema , " " ).
0 commit comments