Skip to content

test(path): cover Optional and Or iterator behavior (#238) - #991

Open
JSap0914 wants to merge 1 commit into
cayleygraph:masterfrom
JSap0914:test/iterator-optional-or-coverage
Open

test(path): cover Optional and Or iterator behavior (#238)#991
JSap0914 wants to merge 1 commit into
cayleygraph:masterfrom
JSap0914:test/iterator-optional-or-coverage

Conversation

@JSap0914

@JSap0914 JSap0914 commented Jul 22, 2026

Copy link
Copy Markdown

Closes #238

What

Adds narrowly scoped integration coverage for the Optional and Or iterators, addressing the low iterator coverage noted in #238. The new cases live in the shared path test set (query/path/pathtest), which is executed against every quadstore backend, so the coverage applies broadly rather than to a single store.

Why

#238 observes that the base iterators are under-covered by the integration tests, specifically the Optional and Or iterators. The most maintainable place to exercise these end-to-end today is the shared testSet in query/path/pathtest, driven via Save/SaveOptional/Optional/Or on the query path (the modern equivalent of the old top-level integration queries the issue refers to).

Coverage added

Against the standard data/testdata.nq graph:

  • Or union of overlapping branchesalice->follows and dani->follows both reach bob; documents that Or is a union without deduplication (bob appears from each branch).
  • Or preserves the Save tag of the producing branch — a value keeps the tag set by whichever Or branch produced it.
  • SaveOptional keeps unmatched starts with an empty tag — starts without a matching quad survive with an empty tag while matched ones carry the value.
  • Optional branch that never matches — every top-level node is still returned when the optional sub-path matches nothing.

Each case runs in both optimized and unoptimized iterator modes (the existing harness runs both), so the assertions pin behavior across optimization.

Verification

gofmt -l query/path/pathtest/pathtest.go   # clean
go vet ./query/path/                        # clean
go test ./query/path/                       # ok
go test ./graph/memstore/                   # ok (runs the shared path test set)

No production code changes; test-only plus a CONTRIBUTORS entry per the project's CONTRIBUTING guidance.

Refs #238


This change is Reviewable

Adds narrowly scoped integration coverage in the shared path test set
(exercised by every quadstore backend) for behaviors that were
previously untested, addressing the low iterator coverage noted in cayleygraph#238:

- Or union of overlapping branches (no deduplication)
- Or preserving the Save tag of whichever branch produced a value
- SaveOptional keeping unmatched starts with an empty tag
- Optional branch that never matches still returning every top-level node

Also adds myself to CONTRIBUTORS per CONTRIBUTING guidance.
@JSap0914
JSap0914 requested review from dennwc and eraserhd as code owners July 22, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Integration Tests using .Save() and .Or()

1 participant