Skip to content

test: restore OpenBestAvailable tests from bgjackma's PR #3143#3150

Merged
maphew merged 2 commits intomainfrom
feat/open-best-available
Apr 9, 2026
Merged

test: restore OpenBestAvailable tests from bgjackma's PR #3143#3150
maphew merged 2 commits intomainfrom
feat/open-best-available

Conversation

@maphew
Copy link
Copy Markdown
Collaborator

@maphew maphew commented Apr 9, 2026

Restores test coverage that was dropped when PR #3149 reimplemented the OpenBestAvailable feature without carrying over @bgjackma's tests from the original PR #3143.

What was lost:

  • TestOpenBestAvailable_ServerMode — verifies server-mode routing works
  • TestOpenBestAvailable_ServerMode_FailsWithoutServer — verifies fail-fast without a server
  • TestOpenBestAvailable_NoCGO_EmbeddedMode_ReturnsError — verifies clear error in !cgo embedded mode
  • TestOpenBestAvailable_NoCGO_NoMetadata_ReturnsError — verifies default (no metadata) requires CGO
  • TestOpenBestAvailable_NoCGO_ServerMode_FailsWithoutServer — verifies server mode works without CGO

Tests are adapted from Brock's original for the current (Storage, Unlocker, error) return signature.

Co-authored-by: Brock Jackman brockj@lyft.com

maphew and others added 2 commits April 9, 2026 11:06
Adds OpenBestAvailable(ctx, beadsDir) which routes to the correct
storage backend based on metadata.json, mirroring the CLI's
newDoltStoreFromConfig logic:

- CGO builds: embedded mode (default) with exclusive flock, or server
  mode when dolt_mode=server
- Non-CGO builds: server mode only, returns clear error for embedded

Returns (Storage, Unlocker, error) so callers manage the flock lifetime.
This fixes the problem where library users of OpenFromConfig silently
got an empty shadow database instead of the actual embedded store.

Amp-Thread-ID: https://ampcode.com/threads/T-019d736a-46a6-7178-91f3-854f36dd474b
Co-authored-by: Amp <amp@ampcode.com>
Restores test coverage that was dropped when PR #3149 reimplemented
the feature without carrying over the tests from bgjackma's original
PR #3143. Tests are adapted for the current (Storage, Unlocker, error)
return signature.

Co-authored-by: Brock Jackman <brockj@lyft.com>
@maphew maphew merged commit bf3a6b2 into main Apr 9, 2026
31 checks passed
seanmartinsmith pushed a commit to seanmartinsmith/beads that referenced this pull request Apr 10, 2026
…3143 (gastownhall#3150)

* feat: add OpenBestAvailable to public API (gastownhall#3143)

Adds OpenBestAvailable(ctx, beadsDir) which routes to the correct
storage backend based on metadata.json, mirroring the CLI's
newDoltStoreFromConfig logic:

- CGO builds: embedded mode (default) with exclusive flock, or server
  mode when dolt_mode=server
- Non-CGO builds: server mode only, returns clear error for embedded

Returns (Storage, Unlocker, error) so callers manage the flock lifetime.
This fixes the problem where library users of OpenFromConfig silently
got an empty shadow database instead of the actual embedded store.

Amp-Thread-ID: https://ampcode.com/threads/T-019d736a-46a6-7178-91f3-854f36dd474b
Co-authored-by: Amp <amp@ampcode.com>

* test: add OpenBestAvailable tests from PR gastownhall#3143

Restores test coverage that was dropped when PR gastownhall#3149 reimplemented
the feature without carrying over the tests from bgjackma's original
PR gastownhall#3143. Tests are adapted for the current (Storage, Unlocker, error)
return signature.

Co-authored-by: Brock Jackman <brockj@lyft.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brock Jackman <brockj@lyft.com>
@maphew maphew deleted the feat/open-best-available branch April 10, 2026 18:17
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.

1 participant