-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Part 4|*] Add unit tests for the previous introduced SQL Backend methods #10292
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
base: elle-payment-sql-series-new
Are you sure you want to change the base?
[Part 4|*] Add unit tests for the previous introduced SQL Backend methods #10292
Conversation
415144d
to
439b619
Compare
439b619
to
c922bc3
Compare
3648e20
to
ae6c366
Compare
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds comprehensive unit tests for the newly introduced SQL backend for the payments database. The changes include refactoring existing tests to be database-agnostic, which is a great improvement for maintainability. The new SQL queries and the Go store implementation are well-structured and cover a wide range of functionalities. My main feedback is on adhering to the testing style guide in the new TestQueryPayments
function, where t.Fatalf
and t.Errorf
should be replaced with assertions from the require
library as mandated by the repository's style guide.
payments/db/payment_test.go
Outdated
if err != nil { | ||
t.Fatalf("unable to create test "+ | ||
"payment: %v", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project's style guide specifies that unit tests must use the require
library for assertions.1 Please replace if err != nil { t.Fatalf(...) }
with require.NoError(t, err, ...)
for consistency and conciseness. This also applies to other t.Fatalf
and t.Errorf
calls in this test function, which should be replaced with appropriate require
assertions (e.g., require.Equal
, require.Len
).
require.NoError(t, err, "unable to create test payment")
Style Guide References
Footnotes
-
The style guide mandates the use of the
require
library for assertions in unit tests to ensure consistency and readability. ↩
In this commit we add all queries which we will need to insert payment related data into the db.
In commit add the harness which will be used to run db agnostic tests against the kv and sql backend. However it does not use it in this commit but it will over the next commits enable these db agnostic tests for the relevant test functions.
Since now the sql backend is more strict in using the same session key we refactor the helper so that we can easily change the session key for every new attempt.
We make the QueryPayments test db agnostic and also keep a small test for querying the duplicate payments case in the kv world.
ae6c366
to
b011ea6
Compare
b011ea6
to
b515aaa
Compare
Now that every method of the interface was implemented we can remove the embedded reference to the KVStore.
We now test every test in the payment_test.go file against all databases.
b515aaa
to
bdbcc54
Compare
This PR adds the DB related unit tests for backend functions which were introduced in #10287 and #10291
and finalizes the implementation for the SQL backend.