Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Incorporate gomega matchers #3489

Merged

Conversation

islamaliev
Copy link
Contributor

Relevant issue(s)

Resolves #3189

Description

Replace the Validator interface with gomega.OmegaMatcher that doesn't assert directly, but instead matches the actual value against the expected value and returns bool as a result. This allows different matchers to be combined.

Moreover, gomega provides a number of very handy matchers that we can use.

@islamaliev islamaliev added the area/testing Related to any test or testing suite label Feb 25, 2025
@islamaliev islamaliev self-assigned this Feb 25, 2025
@islamaliev
Copy link
Contributor Author

islamaliev commented Feb 25, 2025

These are examples of how failed tests look:

--- FAIL: TestQueryCommitsBranchables_SyncsAcrossPeerConnection (0.44s)
    /Users/islam/dev/sourcenetwork/defradb/tests/integration/query/commits/branchables/utils.go:2085: 
        	Error Trace:	/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:2085
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:2036
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:2050
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:1979
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:1818
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:397
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:272
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:220
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/query/commits/branchables/peer_test.go:94
        	Error:      	Expected Cid value to be unique, but ids "age2" and "age" point to the same cid: bafyreidywfgum7d5ceglywjsomjbwaf5qn4zxomye53xdet6acqj77haba
        	Test:       	TestQueryCommitsBranchables_SyncsAcrossPeerConnection
        	Messages:   	Path: commits[3].links[0].cid
--- FAIL: TestP2PWithSingleDocumentUpdatePerNode (0.54s)
    /Users/islam/dev/sourcenetwork/defradb/tests/integration/net/simple/peer/utils.go:2085: 
        	Error Trace:	/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:2085
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:2036
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:1979
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:1818
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:397
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:272
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/utils.go:220
        	            				/Users/islam/dev/sourcenetwork/defradb/tests/integration/net/simple/peer/with_update_test.go:186
        	Error:      	Expected
        	            		45
        	            	to be one of
        	            		[450 600]
        	Test:       	TestP2PWithSingleDocumentUpdatePerNode
        	Messages:   	Path: Users[0].Age

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.49%. Comparing base (fddff39) to head (93665ea).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3489      +/-   ##
===========================================
+ Coverage    78.48%   78.49%   +0.01%     
===========================================
  Files          397      397              
  Lines        37599    37599              
===========================================
+ Hits         29506    29510       +4     
+ Misses        6399     6397       -2     
+ Partials      1694     1692       -2     
Flag Coverage Δ
all-tests 78.49% <ø> (+0.01%) ⬆️

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

see 13 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 fddff39...93665ea. Read the comment docs.

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looking forward to see how this might impact our tests in the future.

@islamaliev islamaliev merged commit 636d1fd into sourcenetwork:develop Feb 26, 2025
42 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Related to any test or testing suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow chaining of test Validators
2 participants