[Xapian-tickets] [Xapian] #337: Extend test of behaviour of databases after close
Xapian
nobody at xapian.org
Wed Apr 4 22:27:36 BST 2018
#337: Extend test of behaviour of databases after close
--------------------------+------------------------------
Reporter: richard | Owner: gp1308
Type: defect | Status: new
Priority: low | Milestone: 1.4.x
Component: Test Suite | Version: SVN trunk
Severity: normal | Resolution:
Keywords: GoodFirstBug | Blocked By:
Blocking: | Operating System: All
--------------------------+------------------------------
Comment (by olly):
I think you're coming at this the wrong way.
A testcase is meant to test what the implemented behaviour should be, not
what how a particular implementation behaves.
So when as here there's a current implementation, you shouldn't start by
testing the current implementation and then writing the test based on
that. The current implementation could be wrong, and if it is then
discovering that is a useful result from this exercise (previous added
test coverage here uncovered a bug - see
2b40b693c2dd15a196b7f2699ec848f804595f80).
So instead think about what the behaviour of these methods should be after
`close()` and write a test for that.
The documented behaviour is that the method should either behave as it
would have before `close()` was called or else throw `DatabaseError`.
For `commit()`, the pre-`close()` behaviour when there are no pending
changes is actually to do nothing so the local behaviour is OK (though a
little odd at first sight). And the remote behaviour is also OK. But it
would also be OK for the local behaviour to be throwing an exception
and/or for the remote behaviour to be doing nothing so the testcase should
accept either behaviour and not test which happens depending on the
backend name. That's also what existing checks in this testcase are
doing.
For transactions, the transaction has no observable effect unless anything
is done within it, so it's probably OK for the calls to do nothing, and
it's certainly OK to throw `DatabaseError`.
If `begin_transaction()` fails, you aren't in a transaction, so
`commit_transaction()` throwing `InvalidOperationError` is correct. If
`begin_transaction()` succeeds, then `commit_transaction()` should either
work or throw `DatabaseError`.
--
Ticket URL: <https://trac.xapian.org/ticket/337#comment:14>
Xapian <https://xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list