defradb icon indicating copy to clipboard operation
defradb copied to clipboard

test: Add Datastore test action for direct value assertions

Open islamaliev opened this issue 10 months ago • 1 comments

Relevant issue(s)

Resolves #3756

Description

This PR introduces a new Datastore test action to the DefraDB integration test framework that enables direct fetching and assertion of values from the datastore. The action provides a flexible builder pattern for constructing keys.

The implementation adds a Datastore struct that accepts a KeyBuilder interface for key construction and uses gomega.OmegaMatcher for value assertions. This allows tests to verify the presence or absence of specific keys in the datastore and assert their values with flexible matchers.

A builder pattern API is provided through the NewKey() factory function, which supports building different key types:

  • DatastoreDoc() builder creates keys for document field values
  • DatastoreIndex() builds keys for index entries

Both builders use collection and document indices that are resolved to actual IDs at runtime, maintaining consistency with the existing test framework patterns.

islamaliev avatar Jun 04 '25 17:06 islamaliev

Codecov Report

:x: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 77.21%. Comparing base (9738f61) to head (d63c30d). :warning: Report is 102 commits behind head on develop.

Files with missing lines Patch % Lines
http/client.go 0.00% 2 Missing :warning:
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3757      +/-   ##
===========================================
- Coverage    77.26%   77.21%   -0.05%     
===========================================
  Files          423      423              
  Lines        38289    38293       +4     
===========================================
- Hits         29583    29566      -17     
- Misses        6840     6855      +15     
- Partials      1866     1872       +6     
Flag Coverage Δ
all-tests 77.21% <50.00%> (-0.05%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
client/db.go 89.29% <ø> (ø)
internal/db/db.go 68.00% <100.00%> (+0.23%) :arrow_up:
http/client.go 52.55% <0.00%> (+0.50%) :arrow_up:

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9738f61...d63c30d. Read the comment docs.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 04 '25 17:06 codecov[bot]