Introduce a JSON output table mechanic #248

Merged
cas merged 2 commits from cr_machinereadable_2 into main 2023-01-12 21:15:22 +00:00
Member
  • Create JSONTable as a proxy/extension to tablewriter which can also output JSON.
  • Implement machine readable output for server list and recipe list
- Create JSONTable as a proxy/extension to tablewriter which can also output JSON. - Implement machine readable output for `server list` and `recipe list`
cas added 1 commit 2023-01-11 02:54:19 +00:00
Introduce a JSON output table mechanic
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
91a2f30136
- Create JSONTable as a proxy/extension to tablewriter which can also output JSON.
- Implement machine readable output for `server list` and `recipe list`
Author
Member

fixes #370

fixes #370
decentral1se reviewed 2023-01-11 10:13:43 +00:00
decentral1se left a comment
Owner

Looks pretty nice!

There seems to be several hacks here (wouldn't be the first in this codebase 🙃), do you expect they'll come back to bite us @cas? Do you have some concerns that it might break in certain ways?

Maybe we could write some tests for this? We have few tests in the codebase but that is because it normally things rely on this hard-to-test CLI > Logic > Output flow.

But here, you can test your implementation of the JsonTable directly? It might be easier. We did that with tagcmp (see the repo for test examples) and it really paid off, there have been very very few bugs and annoyances for people using abra coming from tagcmp because we ironed out a lot first.

Thanks for picking this up!

Looks pretty nice! There seems to be several hacks here (wouldn't be the first in this codebase 🙃), do you expect they'll come back to bite us @cas? Do you have some concerns that it might break in certain ways? Maybe we could write some tests for this? We have few tests in the codebase but that is because it normally things rely on this hard-to-test CLI > Logic > Output flow. But here, you can test your implementation of the JsonTable directly? It might be easier. We did that with [tagcmp](https://git.coopcloud.tech/coop-cloud/tagcmp) (see the repo for test examples) and it really paid off, there have been very very few bugs and annoyances for people using `abra` coming from `tagcmp` because we ironed out a lot first. Thanks for picking this up!
Author
Member

Looks pretty nice!

There seems to be several hacks here (wouldn't be the first in this codebase 🙃), do you expect they'll come back to bite us @cas? Do you have some concerns that it might break in certain ways?

I don't feel too concerned about it breaking. The only thing that worries me is that it has a slightly brittle way of producing JSON and it proxies another type which may change under us (I'm not too concerned about the proxy part since the use in abra of tablewriter is really specific and we'll be able to catch when that changes easily).

Maybe we could write some tests for this? We have few tests in the codebase but that is because it normally things rely on this hard-to-test CLI > Logic > Output flow.

But here, you can test your implementation of the JsonTable directly? It might be easier. We did that with tagcmp (see the repo for test examples) and it really paid off, there have been very very few bugs and annoyances for people using abra coming from tagcmp because we ironed out a lot first.

We could test the JSONTable type, I expect the best tests would just be throwing things at and a) testing if the output is valid JSON (parsable) and b) that the output is identical to a raw tablewriter.Table.

Thanks for picking this up!

No worries, it's great to do this work!

> Looks pretty nice! > > > There seems to be several hacks here (wouldn't be the first in this codebase 🙃), do you expect they'll come back to bite us @cas? Do you have some concerns that it might break in certain ways? I don't feel too concerned about it breaking. The only thing that worries me is that it has a slightly brittle way of producing JSON and it proxies another type which may change under us (I'm not *too* concerned about the proxy part since the use in `abra` of tablewriter is really specific and we'll be able to catch when that changes easily). > Maybe we could write some tests for this? We have few tests in the codebase but that is because it normally things rely on this hard-to-test CLI > Logic > Output flow. > > But here, you can test your implementation of the JsonTable directly? It might be easier. We did that with [tagcmp](https://git.coopcloud.tech/coop-cloud/tagcmp) (see the repo for test examples) and it really paid off, there have been very very few bugs and annoyances for people using `abra` coming from `tagcmp` because we ironed out a lot first. We could test the JSONTable type, I expect the best tests would just be throwing things at and a) testing if the output is valid JSON (parsable) and b) that the output is identical to a raw tablewriter.Table. > Thanks for picking this up! No worries, it's great to do this work!
cas added 1 commit 2023-01-12 04:29:09 +00:00
Add tests to jsontable.
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
c66b26075a
- Test major functionality of jsontable
- Fix bug discovered in testing.
Author
Member

I added tests and in writing the tests discovered a bug in jsontable. Testing Works™.

More tests could be added but I think this should get us a long way there.

I added tests and in writing the tests discovered a bug in jsontable. Testing Works™. More tests could be added but I think this should get us a long way there.
decentral1se approved these changes 2023-01-12 20:18:23 +00:00
decentral1se left a comment
Owner

Solid! LGTM then, merge away 🚀

Solid! LGTM then, merge away 🚀
cas merged commit 514ed766e9 into main 2023-01-12 21:15:22 +00:00
cas deleted branch cr_machinereadable_2 2023-01-12 21:15:27 +00:00
Sign in to join this conversation.
No description provided.