ales-t / rjp

Rapid JSON-lines processor
Apache License 2.0
3 stars 0 forks source link

Test cases #3

Closed zouharvi closed 2 years ago

zouharvi commented 2 years ago

I'm still in the process of transforming the code to be testable (first step is detaching the CLI from the code entry point). @ales-t do you have some test cases which you used during development that could guide me in this?

ales-t commented 2 years ago

I used just really simple files and test cases. For instance, having files like this:

a.json

{"a": 1, "b": 2, "c": "hello"}
{"a": 2, "b": 2, "c": "hello2"}
{"a": 3, "b": 3, "c": "hello3"}

b.json

{"a": 1, "b": 2, "d": "hi from B line 1"}
{"a": 3, "b": 3, "d": "hi from B line 2"}
{"a": 3, "b": 3, "d": "hi from B line 3"}

c.json

{"a": [100, 101, 102], "b": "2", "c": {"foo": "BAR"}}
{"a": [100, 101, 102], "b": "2.0", "c": {"foo": "BAR"}}
{"a": [100, 101, 102], "b": "2000", "c": {"foo": "BAR"}}
{"a": [100, 101, 102], "b": "-100", "c": {"foo": "BAR"}}

I would use commands such as this to test basic functionality:

rjp < a.json join b.json a,b
rjp < c.json e a[0]:first_item,c[foo]:foo_item
rjp < a.json to_tsv a,b
rjp < a.json merge b.json a,b

You can look at README.md and freely combine the steps into pipelines.

That being said, the individual steps should definitely get unit tests and then we can add some end-to-end tests for whole pipelines. I'm planning to add both in the (near) future but since you've already started on making the binary testable, I think we should coordinate the work somehow (e.g. by splitting work on unit tests and work on end-to-end tests?).

ales-t commented 2 years ago

@zouharvi Resolved?

zouharvi commented 2 years ago

Sure. Please add more tests later during development of new features. Currently we only have mock tests.