Fork me on GitHub
#untangled
<
2017-02-26
>
tony.kay00:02:54

Untangled server 0.7.0 released. NOTE: This was a major refactoring, which is why it was delayed. Should be 100% backward compatible, but adds a new more modular way to build servers, including API composition, and easy custom Ring middleware stacks.

tony.kay00:02:21

We're using the modular stuff internally, but not the classic build server function.

tony.kay00:02:09

is a template using the new modular server support

tony.kay00:02:34

Custom Ring, composable API modules, and parser injections as component injections

lucasbradstreet05:02:14

I’m trying to write some tests using untangled.server.protocol-support/check-response-to-client, but I’ve hit some problems with tempids. I tried to use the :om.tempid/my-temp-id form, but there’s some translation to an om.tempid.TempId form somewhere along the way and it all goes wrong. I added a hack to treat om.tempid.TempIds as tempids in that code, and it worked fine with an om generated tempid

lucasbradstreet05:02:39

That issue aside, is there a way to apply a series of mutations to the system, in a similar way to check-response-to-client, or is there a better testing strategy for that.

tony.kay18:02:33

@lucasbradstreet We're kind of on the fence abt protocol support. It was an experiment that had some merit in the idea department, but in our experience it hasn't really given us good overall velocity in testing. The client-side stuff is OK, but I'm leaning much more towards operations on db objects that are easy to reason about (and test, if necessary). The composition of said functions into a mutation is also trivial to test. Integration testing mutations really should not involve as much of the stack as protocol support pushes you towards. In the small, it sounded great. In the large, I lean towards it being too heavy.

tony.kay18:02:31

The approach we take that is working well: 1. We have the database components set up with seeding (using keyword type seeding) 2. We write small integration tests around just the database operation 3. If there is logic around the IO, then that is possibly unit tested (e.g. db op tested in (2) mocked out. THis might be, for example, the security step. 4. Anything else that is tested is more pure code (e.g. client-side mutations are just compositions of functions (f state-map) => state-map or (f table-obj) => table-obj.

tony.kay18:02:22

usually the state-map transforms are just (swap! state (fn [m] (-> (update-in (obj-ident x) do-something-to-x) ...)))

tony.kay18:02:39

e.g. a composition of focusing on tables and table-local operations

tony.kay18:02:16

along with helper functions that encapsulate the swap/update-in (I'm making this up on the spot): (evolve! state (object-ident x) do-something-to-x)

tony.kay18:02:11

or a compositional form (swap! state evolve (object-ident x) do-something-to-x do-something-else)

tony.kay18:02:52

then the vast majority of the code is so stinkin simple you might not choose to write tests for it, and the rest is still quite easy to test.

tony.kay18:02:13

because the ops (except for evolve) are against component-local table maps instead of the app state

tony.kay18:02:21

this also helps with local reasoning

tony.kay18:02:57

So, loooong-answer for a short question. The short answer is "protocol support is a mostly-failed experiment"

tony.kay18:02:14

I would love to delete it, but don't want to break people's existing test suites. I might try moving it out to a deprecated library, so a deps change could suffice for breakage avoidance.

lucasbradstreet21:02:27

@tony.kay thanks for the explanation. I'll stay away from protocol support style tests then. I'm looking forward to your Clojurewest talk

urbank22:02:35

Is anyone using core.spec with untangled? Is the testing library that comes with untangled complementary to it, or a replacement?

sova-soars-the-sora22:02:25

Hey @tony.kay i'm happy to see you on the speakers' list as well 😃

urbank23:02:29

So for a UI child to gain access to a top-level table, its parent has to have access to it?

urbank23:02:49

Or is there a way for a deeply nested child to reach up for an arbitrary database entry?

urbank23:02:23

http://untangled-web.github.io/untangled/guide.html#!/untangled_devguide.D_Queries under query-example-links I can see that you can reach use links [:entities/by-id _]

urbank23:02:34

however, I'm having trouble with a specific use-case that I'm not sure this covers

urbank23:02:24

So basically I have a component that gets a bunch of items from the database. A list of idents and some other fields

urbank23:02:27

This components needs the ability to edit the entites, so I've defined a field in the database that can be changed from this component