test(mock): one failure plan replaces the per-call wrapper drivers

mock.Failures already made a method fail on every call. FailurePlan adds the
call numbers, which is the shape of nearly every device fault the runner has to
survive: the first read times out, the next one works. Expressing that by
embedding the mock in a one-off wrapper put a different seven-line method in
every test that needed one.
This commit is contained in:
pj committed 2026-08-22 21:20:27 +05:30
1 parent 970dc9a6f5
commit 22296c5316
4 files changed
+36 -14

No files matched your search

+1 -1
View File
@@ -130,7 +130,7 @@ func TestRunner_WebInstallsTheStepsLogsInThePage(t *testing.T) {
// be dropped in silence, under a comment claiming it was warned about.
func TestRunner_ReportsALogFetchItCouldNotMake(t *testing.T) {
state := newHarnessWithSpec(t, lastActionSpec)
state.mock.Failures[mockdriver.ActionRecentLogs] = errors.New("adb: device offline")
state.mock.Failures[mockdriver.ActionRecentLogs] = mockdriver.FailurePlan{Err: errors.New("adb: device offline")}
var buffer bytes.Buffer
logger := slog.New(slog.NewTextHandler(&buffer, &slog.HandlerOptions{Level: slog.LevelWarn}))