dittodb icon indicating copy to clipboard operation
dittodb copied to clipboard

Use `commit`s to show altered state

Open jonkeane opened this issue 5 years ago • 0 comments

In general, the mocks don't care about the state of the database. However some test cases might want to manipulate the state and get two different results from the same query on the same db before and after a state change.

example

dbGetQuery(con, "SELECT name, date from transactions ORDER BY DESC date LIMIT 1")
# the most recent name and date from transactions

# add new transactions
dbAppendTable(con, name = "date", value = new_transactions)

dbGetQuery(con, "SELECT name, date from accounts ORDER BY DESC date LIMIT 1")
# the *new!) most recent name and date from transactions

Currently, because the queries before and after the append are the same, the results would be the same. But if we start a new state after the append (because it presumably includes a commit command) we can have different responses before and after the append.

This is similar to httptest::change_state()

jonkeane avatar Oct 16 '19 16:10 jonkeane