luminus-framework / luminus-framework/guestbook

db tests sometimes fail when run from repl

Open
#21 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
41
Forks
17
PR merge metrics
No merged PRs in 30d

Description

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"})))

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test/clj/guestbook/test/db/core.clj at the linked setup and test lines, then compare the REPL path with lein test. Read project.clj, profiles.clj, cprop, and the mount/start entry point to trace which database environment is selected. Done means the database tests run from cider-repl against an isolated test database without data from the development database.

Written by the indexing model from the issue text.

Assessment

Domain
database, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.