component

tetriscodes 2016-10-27T18:06:12.000127Z

Anybody got a tutorial or some knowledge on how to test a component and interact with it in the repl?

tetriscodes 2016-10-27T18:06:32.000128Z

Or is the idea to test the system as a whole and the components will get tested as the system gets tested?

tetriscodes 2016-10-27T18:07:26.000129Z

Currently the only way in my system is through HTTP and MQTT.

roberto 2016-10-27T18:51:13.000130Z

in the repl, just start the component: (def db-component-instance (component/start my-component))

roberto 2016-10-27T18:51:34.000131Z

then you can use that in the repl.

roberto 2016-10-27T18:52:14.000132Z

there is nothing special you need to do to test them, other than just start them and pass it to the function that needs to use it.

seancorfield 2016-10-27T20:28:44.000133Z

@tetriscodes You can create (and test) any individual component in the REPL (and the Component docs give examples). Not quite sure what you’re asking…?

tetriscodes 2016-10-27T20:46:39.000134Z

Just what is best practice, Test the Components vs Test the system’s surface

tetriscodes 2016-10-27T20:48:39.000135Z

@seancorfield I coudnt find the docs. I see very little on the github readme about testing

seancorfield 2016-10-27T20:49:49.000136Z

So much is going to depend on what the component actually is. Mostly, components are just some data / state with initialization (and possibly termination) code.

seancorfield 2016-10-27T20:50:14.000137Z

In general you’re going to be testing functions that depend on components (i.e., take components as arguments).

seancorfield 2016-10-27T20:50:44.000138Z

So you don’t really “test the component”, except insofar as you can test that it starts / stops correctly.

seancorfield 2016-10-27T20:52:24.000139Z

The docs for Component say that you don’t pass the entire system around everywhere in your code, only the subcomponents that are needed by a particular set of functions. When you’re testing those functions, you only need the subcomponent so you can create just that part with system-map sometimes, or the “constructor” function for the record that has your start/stop functionality.

seancorfield 2016-10-27T20:52:54.000140Z

Does that help? If not, can you be more precise about what you’re asking…?

roberto 2016-10-27T20:55:41.000141Z

for example, how would you test a database connection in another programming language? You don’t really, at least I have never done that. In component, you might have a Database component that holds a connection (or pool of connections) to a database that other parts of your system depend on to communicate with the database. If I felt the need to test a Database component, for example, I would probably just inspect its properties to see if a connection was open, and then close it and verify that it was closed. There really isn’t much to test. The other way, which is probably done more than once through out the system, is to only test those functions that depend on the database component.