Skip to content

Commit

Permalink
Test recursively defined Avro record
Browse files Browse the repository at this point in the history
  • Loading branch information
Alastair Hole committed Jun 20, 2022
1 parent 35a8c2f commit 8c86cc0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/jackdaw/serdes/avro_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@
:type "record"
:fields [{:name "stringField"
:type "string"}
{:name "recursiveRecord"
:type ["null" "testRecord"]
:default nil}
{:name "longField"
:type "long"}
{:name "optionalField"
Expand All @@ -385,7 +388,7 @@
(is (avro/match-clj? schema-type clj-data-opt))
(is (not (avro/match-clj? schema-type (assoc clj-data-opt :optionalField (inc (long Integer/MAX_VALUE))))))
(is (not (avro/match-clj? schema-type (assoc clj-data-opt :optionalField (dec (long Integer/MIN_VALUE))))))
(is (= (assoc clj-data :optionalField nil :defaultField 1) (avro/avro->clj schema-type avro-data)))
(is (= (assoc clj-data :optionalField nil :defaultField 1 :recursiveRecord nil) (avro/avro->clj schema-type avro-data)))
(is (= avro-data (avro/clj->avro schema-type clj-data [])))
(is (instance? Integer (.get (avro/clj->avro schema-type clj-data-opt []) "optionalField")))))
(testing "marshalling record with unknown field triggers error"
Expand Down

0 comments on commit 8c86cc0

Please sign in to comment.