Skip to content

bindings-uniffi has no tests #8

Description

@yncyrydybyl

Problem

`bindings-uniffi/src/lib.rs` has 260+ lines of wrapper code exposing `FaffWorkspace` to foreign consumers, but zero tests. No `#[cfg(test)]` module exists anywhere in the crate.

The binding currently relies entirely on faff-tui (the Go consumer) as its integration test. When something breaks at the FFI boundary, we find out from a broken Go build downstream — not from CI on this repo.

Coverage gap

Every exposed method in the UDL is untested at the binding layer:

  • `FaffWorkspace` constructor (tokio runtime init, workspace init)
  • `get_log` — date parsing, RFC3339 string conversion for time fields
  • `start_session`, `stop_current_session`, `update_active_session`
  • `update_session_at` (the one this is a follow-up for)
  • Vocabulary queries: `get_roles`, `get_impacts`, `get_modes`, `get_subjects`, `get_trackers`, `get_session_hints`
  • `recent_prototypes` — the binding-side dedup/ranking logic, which is NOT covered by core tests since it lives in the binding

Why this matters

  1. Error mapping is lossy. `anyhow::Error` → `FaffError::Other` via string matching. A behavior change in core's error messages can silently change the FFI error variant with no signal.
  2. Type conversions are manual. RFC3339 string round-trips, `Vec` sort order, `ProtoKey` dedup by tuple — all implemented by hand in lib.rs, zero coverage.
  3. Runtime ownership. The binding owns its tokio runtime (vs bindings-python's per-call creation). If that invariant changes, nothing catches it.
  4. `recent_prototypes` is binding-only logic. Walks logs, groups by tuple key, ranks by count + recency. ~60 lines of code, zero tests.

Suggested fix

Add a `#[cfg(test)]` module to `bindings-uniffi/src/lib.rs` with tests that:

  • Use the same `MockStorage` + `create_test_workspace` pattern as core's tests
  • Exercise each method's happy path + at least one error path
  • Cover `recent_prototypes` dedup and ranking with hand-constructed logs
  • Verify RFC3339 round-trip for `start` / `end` fields (parse → serialize matches)
  • Assert error variant mapping (`FaffError::InvalidDate`, `NoActiveSession`, `Other`)

Target: ~15 tests, ~250 lines. Same volume as `bindings-python/tests/test_python_bindings.py` which covers the parallel PyO3 surface.

Related

  • CI (`.github/workflows/ci.yml`) already runs `cargo test --workspace --all-features` which would pick up new tests in `bindings-uniffi` automatically. No CI changes needed.
  • Parallel gap for `bindings-wasm` (1 smoke test only) tracked separately if desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions