Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db tests sometimes fail when run from repl #21

Open
zlrth opened this issue Aug 31, 2017 · 1 comment
Open

db tests sometimes fail when run from repl #21

zlrth opened this issue Aug 31, 2017 · 1 comment

Comments

@zlrth
Copy link

zlrth commented Aug 31, 2017

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.

[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]

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"})))
@yogthos
Copy link
Member

yogthos commented Sep 1, 2017

Yeah I think this is the same cause as this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants