Answer stability round 1: 0 🔴, 14 🟡 (0 misread); tests that kill the surviving mutants, with a versioned MemoryStore and appended_to, plan/named_paths.py, TakenIn's docstring and the run-heavy rule naming LAUNCHERS; three places left to item 300
CI / tests (pull_request) Successful in 3m10s
CI / tests (pull_request) Successful in 3m10s
This commit is contained in:
@@ -7,20 +7,25 @@ from record_store.held import Held
|
||||
|
||||
@dataclasses.dataclass
|
||||
class MemoryStore:
|
||||
"""A record held in memory, as a backend outside git holds one. Set fails to make every read and write fail with that reason."""
|
||||
"""A record held in memory, as a backend outside git holds one: versioned as a wiki page is, refusing a write over a version it no longer holds. Set fails to make every read and write fail with that reason. overs holds the version each write named, so a test can check that a caller wrote over the version it read."""
|
||||
text: str = ""
|
||||
label: str = "the record in memory"
|
||||
tracked: str | None = None
|
||||
fails: str | None = None
|
||||
version: int = 0
|
||||
overs: list[str | None] = dataclasses.field(default_factory=list)
|
||||
|
||||
def read(self) -> str | Failure:
|
||||
return Failure(self.fails) if self.fails else self.text
|
||||
|
||||
def held(self) -> Held | Failure:
|
||||
return Failure(self.fails) if self.fails else Held(self.text)
|
||||
return Failure(self.fails) if self.fails else Held(self.text, str(self.version))
|
||||
|
||||
def write(self, text: str, over: str | None) -> Held | Failure:
|
||||
self.overs.append(over)
|
||||
if self.fails:
|
||||
return Failure(self.fails)
|
||||
self.text = text
|
||||
return Held(text)
|
||||
if over is not None and over != str(self.version):
|
||||
return Failure(f"someone saved {self.label} since version {over}")
|
||||
self.text, self.version = text, self.version + 1
|
||||
return Held(text, str(self.version))
|
||||
|
||||
Reference in New Issue
Block a user