-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: create endpoint to register customers #28
Conversation
…register-customers # Conflicts: # .docker/setup.sql # docker-compose.yml # src/FIAP.TechChallenge.ByteMeBurger.Api/Configuration/MySqlSettings.cs # src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs # src/FIAP.TechChallenge.ByteMeBurger.Api/appsettings.Development.json
WalkthroughThe recent updates focus on enhancing the application's infrastructure, error handling, and overall robustness. Changes include adding MySQL support alongside MongoDB, refining error messages, improving health checks, and restructuring service configurations. The codebase underwent reorganization for clarity and maintainability, introducing new classes for service registration, database configuration, and repository patterns. These modifications aim to enhance the application's functionality and developer experience. Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 4
Out of diff range and nitpick comments (1)
src/FIAP.TechChallenge.ByteMeBurger.Infrastructure/Repository/InMemoryOrderRepository.cs (1)
Line range hint
27-27
: Mismatch in nullability between the method's return type and the actual returned value. Ensure consistency to avoid runtime issues.- return Task.FromResult<Order?>(null); + return Task.FromResult<Order?>(null);
MYSQL_DATABASE=techchallenge | ||
MYSQL_PORT=3306 | ||
MYSQL_USERID=techchallenge | ||
MYSQL_PASSWORD=techchallengeFIAP |
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.
Ensure that sensitive information such as MYSQL_PASSWORD
is securely managed and not hardcoded in environment files in production environments.
builder.Services.AddHealthChecks() | ||
.AddMySql(provider => provider.GetRequiredService<DbConnectionStringBuilder>().ConnectionString); |
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.
Tip
Codebase Verification
The verification process has revealed that the appsettings.json
file does not contain the necessary ConnectionString
key required for the MySQL database connection. This is a critical issue as the application relies on this connection string to interact with the database. It is recommended to add the appropriate connection string configuration to ensure the application functions correctly.
- Please add the
ConnectionString
key with the correct format to theappsettings.json
file.
Analysis chain
Added MySQL health check. Verify that the connection string provided matches the expected format and contains all necessary information.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the MySQL connection string format in the configuration.
# Check the connection string format in the configuration file.
grep 'ConnectionString' src/FIAP.TechChallenge.ByteMeBurger.Api/appsettings.json
Length of output: 80
Script:
#!/bin/bash
# Check if the appsettings.json file exists and list its contents
if [ -f src/FIAP.TechChallenge.ByteMeBurger.Api/appsettings.json ]; then
echo "appsettings.json exists."
cat src/FIAP.TechChallenge.ByteMeBurger.Api/appsettings.json
else
echo "appsettings.json does not exist."
fi
Length of output: 341
[Fact] | ||
public async Task FindByCpf_Success() | ||
{ | ||
// Arrange | ||
var expectedCustomer = new Customer(Cpf, "italo", "italo@gmail.com"); | ||
|
||
_mockConnection.SetupDapperAsync(c => c.QuerySingleOrDefaultAsync<Customer>(It.IsAny<string>(), null, null, null, null)) | ||
.ReturnsAsync(expectedCustomer); | ||
|
||
// Act | ||
var result = await _target.FindByCpfAsync(Cpf); | ||
|
||
// Assert | ||
using (new AssertionScope()) | ||
{ | ||
result.Should().NotBeNull(); | ||
result.Should().Be(expectedCustomer); | ||
} | ||
} |
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 FindByCpf_Success
test method effectively tests the scenario where a customer is found. Consider adding more detailed assertions to verify the properties of the returned customer object.
- result.Should().Be(expectedCustomer);
+ result.Should().BeEquivalentTo(expectedCustomer, options => options.ComparingByMembers<Customer>());
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
[Fact] | |
public async Task FindByCpf_Success() | |
{ | |
// Arrange | |
var expectedCustomer = new Customer(Cpf, "italo", "italo@gmail.com"); | |
_mockConnection.SetupDapperAsync(c => c.QuerySingleOrDefaultAsync<Customer>(It.IsAny<string>(), null, null, null, null)) | |
.ReturnsAsync(expectedCustomer); | |
// Act | |
var result = await _target.FindByCpfAsync(Cpf); | |
// Assert | |
using (new AssertionScope()) | |
{ | |
result.Should().NotBeNull(); | |
result.Should().Be(expectedCustomer); | |
} | |
} | |
[Fact] | |
public async Task FindByCpf_Success() | |
{ | |
// Arrange | |
var expectedCustomer = new Customer(Cpf, "italo", "italo@gmail.com"); | |
_mockConnection.SetupDapperAsync(c => c.QuerySingleOrDefaultAsync<Customer>(It.IsAny<string>(), null, null, null, null)) | |
.ReturnsAsync(expectedCustomer); | |
// Act | |
var result = await _target.FindByCpfAsync(Cpf); | |
// Assert | |
using (new AssertionScope()) | |
{ | |
result.Should().NotBeNull(); | |
result.Should().BeEquivalentTo(expectedCustomer, options => options.ComparingByMembers<Customer>()); | |
} | |
} |
@coderabbitai could you create a readme file describing this repository and how you can test it after cloning the repository? |
Tip For best results, initiate chat on the files or code changes. @italopessoa Here's a draft for the README file that describes the repository and provides instructions on how to test it after cloning: # FIAP Tech Challenge - ByteMeBurger API
## Description
This repository contains the source code for the ByteMeBurger API, part of the FIAP Tech Challenge. The API is designed to manage a burger restaurant's operations, including order placement, customer registration, and product management. The recent updates introduce a new endpoint for customer registration and enhance various aspects of the application, such as error handling, data models, and service configurations.
## Getting Started
### Prerequisites
- Docker
- .NET SDK
- Optionally, an IDE such as Visual Studio or VSCode
### Setup
1. Clone the repository:
```bash
git clone https://github.com/soat-fiap/FIAP.TechChallenge.ByteMeBurger.git
cd FIAP.TechChallenge.ByteMeBurger
TestingTo run the automated tests included in the repository, use the following command: dotnet test This command will execute all tests defined in the test projects and provide a summary of the test results. ContributingContributions to the project are welcome! Please refer to the contributing guidelines for more information on how to submit pull requests. LicenseThis project is licensed under the MIT License - see the LICENSE.md file for details.
|
No description provided.