Skip to content

Conversation

ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Oct 14, 2025

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.

@ziggie1984 ziggie1984 changed the base branch from master to elle-payment-sql-series-new October 14, 2025 09:34
@saubyk saubyk added this to v0.21 Oct 14, 2025
@saubyk saubyk moved this to In progress in v0.21 Oct 14, 2025
@ziggie1984 ziggie1984 changed the title [Part 4|*] Implement FetchInFlightPayments for SQL Backend [Part 4|*] Add unit tests for the previous introduced SQL Backend methods Oct 15, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-4 branch 3 times, most recently from 415144d to 439b619 Compare October 15, 2025 16:28
@ziggie1984 ziggie1984 marked this pull request as ready for review October 15, 2025 16:29
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-4 branch from 439b619 to c922bc3 Compare October 15, 2025 17:02
@ziggie1984 ziggie1984 added this to the v0.21.0 milestone Oct 15, 2025
@ziggie1984 ziggie1984 added payments Related to invoices/payments sql labels Oct 15, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-4 branch 7 times, most recently from 3648e20 to ae6c366 Compare October 17, 2025 07:52
@ziggie1984
Copy link
Collaborator Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 2270 to 2273
if err != nil {
t.Fatalf("unable to create test "+
"payment: %v", err)
}

Choose a reason for hiding this comment

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

medium

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

  1. 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.
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-4 branch from ae6c366 to b011ea6 Compare October 17, 2025 08:43
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-4 branch from b011ea6 to b515aaa Compare October 17, 2025 11:09
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-4 branch from b515aaa to bdbcc54 Compare October 17, 2025 11:12
@ziggie1984 ziggie1984 moved this from In progress to In review in v0.21 Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

payments Related to invoices/payments sql

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant