Fork me on GitHub
#beginners
<
2016-05-19
>
djtango13:05:42

hey all wonder if anyone is available to field a question about testing?

roberto13:05:20

basic rule of chat rooms: don’t ask permission to ask, just ask.

djtango13:05:41

ha okay - so I am actually from the Racket community, though have coded in Clojure too. This is more of a high level question: I want to set up my integration tests so that the database cleans up after itself, i.e. after incurring database side-effects, the database will do a rollback. My difficulty is when feature testing with rollbacks - I can transactions working with unit testing. If I make a test request to the server, the server will do database stuff but if I wrap the request to the server in a transaction, the rollback doesn't undo the changes the server makes - presumably because the test and the server are interacting with the database with separate sessions. Has this problem been solved in Clojure?

roberto14:05:48

not sure I understand

roberto14:05:56

are you using the same database for testing, development and production?

roberto14:05:12

that is what I’m understanding from your explanation

djtango14:05:43

dev and prod are separate - we'll be implementing test at a later stage

djtango14:05:59

but at the moment, the testing framework behaves as the client and launches a request, the server then writes to the database - is there a way to wrap each test in a transaction so that it can rollback between tests? I've done this in Ruby using DatabaseCleaner

roberto14:05:07

normally, tests also have their own db for testing

roberto14:05:22

oh, you have functional tests?

roberto14:05:54

when we do that, we test on a separate instance of the server that is not connected to the production database

djtango14:05:06

and then you don't do rollbacks?

djtango14:05:14

so they're effectively live tests, just automated

roberto14:05:21

doesn’t matter, the tests won’t pollute real data

roberto14:05:28

it minimizes the damage that can be done to the data

djtango14:05:59

ah ok - so at the functional/feature test level, rolling back your database is less of an issue? Only at unit test level do you do rollbacks?

djtango14:05:15

you just make sure you do your testing on a separate server + DB instance?

donaldball15:05:48

I always do my testing on a separate db instance, or at least a db instance I don’t mind being wiped out by my tests

donaldball15:05:43

I never use transactional rollbacks to revert db state. I see the appeal, but I always control my db transactions explicitly in my app code. Put another way, transactional guarantees are a property of my database interaction which I very much care to specify in my tests.

donaldball15:05:30

When and if I get to the point where my database interaction in tests are so pervasive as to become annoying or slow, I’ll look to introducing a protocol with a smaller surface area which I can specifically test in integration with the db, and reify a mock implementation for testing with dependent components.

djtango15:05:53

thanks @donaldball - great food for thought

djtango16:05:28

If you are using truncations to clean your DBs for testing, do you therefore have jobs/helpers to seed your database if you need some sample data for later tests? Has this proved particularly time consuming to do?

donaldball16:05:18

I strongly prefer to establish the givens for each test in the preamble. When I find I need many helpers to create the state I need for a test I view as a sign that I should probably look to simplify, perhaps by introducing an abstraction

virmundi16:05:11

Hello. is this the right place to ask about setting up Sublime + Reloaded + REPL?

surreal.analysis18:05:45

@virmundi: Sure, if you have a question, just ask! You might also get a better response in #C050AN6QW, but here is just fine too

agi_underground20:05:51

Hi, this is i am again. My problem is how to enable http2 to my project, that use jetty server. I think i can not add param --add-to-startd=http2 becouse my project use jetty like internal entity, i have defined dependency in project.clj, and in this way, my project use already compiled jar file from .m2/repository/org/eclipse/jetty/jetty-server/9.3.8.v20160314 and becouse this i can not set my own params to enable http2. Maybe someone already configured jetty to use http2 in projects? How i can do this?