Skip to content

Database-user-repositories#1

Merged
staa99 merged 17 commits intodevelopfrom
database-user-repositories
Mar 2, 2025
Merged

Database-user-repositories#1
staa99 merged 17 commits intodevelopfrom
database-user-repositories

Conversation

@laken11
Copy link
Copy Markdown
Collaborator

@laken11 laken11 commented Jan 27, 2025

Pull Request Title

Description

Summary

Worked on database connection, user repository with test cases, project repository with test cases

Motivation

Explain the reason for these changes. Why is it needed? What problem does it solve?

Related Issue(s)

  • Issue(s): Link any related issues here (e.g., closes #123, fixes #456).

Detailed Changes

  • New Features/Enhancements: List the new features or enhancements introduced.
  • Bug Fixes: List any bugs that were fixed, including their severity.
  • Refactor: Describe any code refactoring done to improve the structure without altering functionality.
  • Documentation: Mention if there are any updates to documentation.

Checklist

Code Quality

  • Correctness: Ensure the code is correct and fulfills the intended purpose.
  • Code Simplicity: Verify that the code is simple and avoids unnecessary complexity.
  • Style: Confirm that the code adheres to the project's coding standards and guidelines.
  • Naming: Ensure variable and function names are descriptive and meaningful.
  • Comments: Verify that all non-obvious code is well-commented.

Testing

  • Unit Tests: Ensure unit tests are present and cover the new code adequately.
  • Test Accuracy: Verify that tests are accurate and verify the correct behavior of the code.
  • Test Coverage: Check that the tests cover all edge cases and potential failure points.
  • CI/CD: Ensure that the PR passes all continuous integration and continuous deployment checks.

<< Provide screenshots that show the test coverage after your PR >>

Security

  • Security Concerns: Review for any potential security vulnerabilities.
  • Data Handling: Verify that sensitive data is properly handled (e.g., no hardcoded credentials).
  • Input Validation: Ensure all user inputs are validated and sanitized.

Documentation

  • Documentation Updated: Ensure any new features or changes are well-documented.
  • ReadMe/Changelog: Update the ReadMe or Changelog if necessary.

Dependencies

  • Dependency Updates: List any updates to external dependencies and the reasons for these updates.
  • Backward Compatibility: Confirm that changes are backward-compatible or provide migration steps.

Deployment

  • Deployment Considerations: Identify any special considerations for deploying these changes (e.g., database migrations).

Reviewer Selection

  • Assign the team lead on the project for review.
  • Assign a team member who is familiar with the codebase for a second review.
  • Merge the PR only after receiving an approval. Deployment-triggering PRs should be merged by the team lead.

Branch Deletion

  • Branch Deleted: After the PR is merged, delete the branch if it is no longer needed.

Reviewer Notes

General Review

  • Understanding: Confirm that you understand the changes made in this PR.
  • Ask Questions: Leave comments or ask questions if any part of the PR is unclear.
  • Review Thoroughly: Review the code thoroughly to catch any potential issues.

Final Approval

  • Approve: If all checks are satisfactory, approve the PR.
  • Request Changes: If there are issues, request changes and detail what needs to be addressed.

@laken11 laken11 requested a review from staa99 January 27, 2025 19:28
Comment on lines +20 to +40
context = {
isDbContext: true as boolean,
entrypoint: 'test',
logger: createLogger({ context: 'test' }) as BonadocsLogger,

// Mock query method
query: jest.fn().mockImplementation(() =>
Promise.resolve({
rowCount: 0,
rows: [],
oid: 0,
fields: [],
command: '',
} as QueryResult),
),

// Mock transaction methods
beginTransaction: jest.fn().mockImplementation(() => Promise.resolve()),
commitTransaction: jest.fn().mockImplementation(() => Promise.resolve()),
rollbackTransaction: jest.fn().mockImplementation(() => Promise.resolve()),
} as unknown as DbContext;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Create a test utility function to provide a mock DbContext


describe('getContractAbiHash', () => {
it('should return null if no contract is found', async () => {
(context.query as jest.Mock).mockImplementation(() =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if you use jest.Mocked from above, this cast is unnecessary

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make the update across all of your test functions

describe('getContractAbiHash', () => {
it('should return null if no contract is found', async () => {
(context.query as jest.Mock).mockImplementation(() =>
Promise.resolve({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use mockResolvedValue rather than mockImplementation. It's a utility to achieve the same thing but it's neater.

@laken11 laken11 changed the base branch from main to develop March 2, 2025 07:49
@staa99 staa99 merged commit 04dffb7 into develop Mar 2, 2025
2 checks passed
@staa99 staa99 deleted the database-user-repositories branch March 2, 2025 07:50
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.

2 participants