Read and write each record through the store its config names, and open one for agents with project-record
CI / tests (pull_request) Successful in 2m14s
CI / tests (pull_request) Successful in 2m14s
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""What every record backend must hold, as tests. A backend's test case inherits RecordStoreContract and unittest.TestCase, and builds its store in new_store."""
|
||||
import typing
|
||||
|
||||
from record_store.stores import held_at, RecordStore
|
||||
|
||||
|
||||
class RecordStoreContract:
|
||||
"""Runs against the store new_store returns: one that holds no record yet."""
|
||||
assertEqual: typing.Callable[..., None]
|
||||
assertIsNone: typing.Callable[..., None]
|
||||
assertTrue: typing.Callable[..., None]
|
||||
|
||||
def new_store(self) -> RecordStore:
|
||||
raise NotImplementedError
|
||||
|
||||
def test_a_record_never_written_reads_empty(self) -> None:
|
||||
self.assertEqual(self.new_store().read(), "")
|
||||
|
||||
def test_reads_back_what_it_wrote_to_the_character(self) -> None:
|
||||
store = self.new_store()
|
||||
text = "# Decisions\n\n- Å, 🔴 and a | pipe\n\n\n"
|
||||
self.assertIsNone(store.write(text))
|
||||
self.assertEqual(store.read(), text)
|
||||
|
||||
def test_a_write_replaces_the_whole_record(self) -> None:
|
||||
store = self.new_store()
|
||||
store.write("first\nsecond\n")
|
||||
self.assertIsNone(store.write("third\n"))
|
||||
self.assertEqual(store.read(), "third\n")
|
||||
|
||||
def test_names_itself_for_a_message(self) -> None:
|
||||
self.assertTrue(self.new_store().label.strip())
|
||||
|
||||
def test_reads_as_it_stands_at_any_revision_where_no_commit_holds_it(self) -> None:
|
||||
store = self.new_store()
|
||||
store.write("as it stands\n")
|
||||
if store.tracked is None:
|
||||
self.assertEqual(held_at("no-such-revision", store, "/nowhere", run=refuse), "as it stands\n")
|
||||
|
||||
|
||||
def refuse(*args: str, **options: object) -> str:
|
||||
raise AssertionError(f"git {' '.join(args)} ran for a record no commit holds")
|
||||
Reference in New Issue
Block a user