bartkl / metamorph

Metamorph is a Clojure libary that enables the generation of an Avro schema from a given input SHACL model.
https://bartkl.github.io/metamorph/
Apache License 2.0
2 stars 3 forks source link

Write first unit tests and perhaps specs #20

Closed bartkl closed 1 year ago

bartkl commented 2 years ago

This is just to get things started. By no means is it the intention here to have a significant amount of coverage. We just want to get our feet wet using clojure.test and perhaps experiment (a little!) with clojure.spec.

bartkl commented 2 years ago

Note: make sure to use more meaningful test data than the current single letter data. Having stuff like Car and Vehicle can really make your test data easier to reason about. Now it's totally unclear what relations A and B have to each other until I check.

bartkl commented 2 years ago

Probably nice to start testing something stateful like the Asami db. This way we'll learn how to do resource management (fixtures, setup/teardown mechanisms, ...).

bartkl commented 1 year ago

Currently implementing something like an integration test in metamorph.core-test and walking into trouble.

Problem

When outputting avro.json, then copying it as avro_success.json to serve as "expected" data, it turns out reading both as JSON does not entail equivalence.

The problem turns out to be - at least! - that recurring records (like B and D) can have different orders in which they appear, depending on which properties of the root B node shape are processed first. This could be an order issue probably with Asami already, although it's possible the issue stems in Lancaster when actual references are made. I'm not sure where the issue occurs.

Another thing to watch out for: do the fields vectors have the same order? Because with vectors this could matter too.

What to do