I can’t figure out how to run tests that use a test database from my cider-repl. lein test works as intended, for what it's worth.
But when I run the the test in the test-db namespace[1], it creates a dev database (./guestbook_dev.db).
This means that if I, from the repl, (start), then add something to the db using the form at localhost:3000, then run the db test, the db test fails[3].
I think this is because the mount/start function is creating an environment using the dev profile.[2] I'd open a pull request for your review, but I don't know enough about mount, profiles.clj, cprop, and possibly other things. I suspect that using the :test profile in project.clj would do it, but I don't know how to tell mount/start to use it.
guestbook.test.db.core
Tested 1 namespaces
Ran 4 assertions, in 1 test functions
3 failures
Results
guestbook.test.db.core
3 non-passing tests:
Fail in test-message
expected: 1
actual: (2)
Fail in test-message
expected: {:name "test",
:message "test",
:timestamp #inst "2017-08-31T18:29:42.400-00:00"}
actual: ({:name "name from form",
:message "this is the message i entered into the form",
:timestamp #inst "2017-08-31T18:29:26.477000000-00:00"})
Fail in test-message
expected: (empty? (db/get-messages))
actual: (not
(empty?
({:id 2,
:name "name from form",
:message "this is the message i entered into the form",
:timestamp #inst "2017-08-31T18:29:26.477000000-00:00"})))
I can’t figure out how to run tests that use a test database from my cider-repl.
lein test
works as intended, for what it's worth.But when I run the the test in the test-db namespace[1], it creates a dev database (./guestbook_dev.db).
This means that if I, from the repl,
(start)
, then add something to the db using the form atlocalhost:3000
, then run the db test, the db test fails[3].I think this is because the
mount/start
function is creating an environment using thedev
profile.[2] I'd open a pull request for your review, but I don't know enough about mount, profiles.clj, cprop, and possibly other things. I suspect that using the:test
profile in project.clj would do it, but I don't know how to tell mount/start to use it.[1] https://github.com/luminus-framework/guestbook/blob/master/test/clj/guestbook/test/db/core.clj#L18 [2] https://github.com/luminus-framework/guestbook/blob/master/test/clj/guestbook/test/db/core.clj#L13 [3]