Skip to content

Commit 283d540

Browse files
test(examples): let mock_file_source simulate an ingest failure via fail_start (#128)
The mock_file_source example doubles as the shared test fixture for PlotJuggler's file-loader tests. Add a test-only failure-injection hook: when its config contains the `fail_start` marker, importData() returns an error instead of writing rows. This is needed because the host creates a dataset in the live engine BEFORE importData() runs, so a source that loads/binds successfully but then fails during ingest is the only way to exercise the host's abandoned-dataset cleanup path. The existing deliberately-broken sibling plugins fail at discovery (before the dataset exists), so they can't reach that path. Scope: example/test plugin only — no installed header, no ABI, no canonical-object change — so no SDK version bump (stays 0.8.1). config_ is matched by substring to keep the example JSON-dependency-free; only tests set this config. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 75b4849 commit 283d540

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

pj_plugins/examples/mock_file_source.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ class MockFileSource : public PJ::FileSourceBase {
2222
}
2323

2424
PJ::Status importData() override {
25+
// Test-only failure injection: the host creates the dataset in the live engine
26+
// before importData() runs, so returning an error here lets tests exercise the
27+
// host's abandoned-dataset cleanup. config_ is opaque to this example (no JSON
28+
// dependency), so the marker is matched by substring — safe because only tests
29+
// set this config.
30+
if (config_.find("fail_start") != std::string::npos) {
31+
return PJ::unexpected("mock_file_source: configured start failure");
32+
}
33+
2534
if (!runtimeHost().progressStart("Importing", 3, true)) {
2635
return PJ::unexpected("progress unavailable");
2736
}

0 commit comments

Comments
 (0)