File tree Expand file tree Collapse file tree 7 files changed +124
-2
lines changed Expand file tree Collapse file tree 7 files changed +124
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ type ScraperImpl struct {
18
18
19
19
// CleanPrice implements Scraper.
20
20
func (s * ScraperImpl ) CleanPrice (price string ) ([]int , error ) {
21
- // Expresión regular que captura secuencias de números (con o sin separadores de miles)
21
+ // Captura numeros entre 1 y 3 digitos d{1,3} seguidos de 0 o más
22
+ // grupos de 3 digitos (?:\.\d{3})* antesedidos por un punto
23
+ // EJ: 123.456.789 sería \d{1,3} = 123 y (?:\.\d{3})* = .456.789
22
24
re := regexp .MustCompile (`\d{1,3}(?:\.\d{3})*` )
23
25
24
26
// Encontrar todas las coincidencias
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ package response
3
3
type UserResponse struct {
4
4
UserID string `json:"user_id" validate:"required"`
5
5
Username string `json:"username" validate:"required"`
6
- Email string `json:"email" validate:"required"`
6
+ Email string `json:"email" validate:"required,email "`
7
7
}
Original file line number Diff line number Diff line change
1
+ package mocks
2
+
3
+ import (
4
+ "github.com/aws/aws-sdk-go/service/dynamodb"
5
+ "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
6
+ "github.com/stretchr/testify/mock"
7
+ )
8
+
9
+ type MockDynamoDB struct {
10
+ dynamodbiface.DynamoDBAPI
11
+ mock.Mock
12
+ }
13
+
14
+ func (m * MockDynamoDB ) Query (input * dynamodb.QueryInput ) (* dynamodb.QueryOutput , error ) {
15
+ args := m .Called (input )
16
+ return args .Get (0 ).(* dynamodb.QueryOutput ), args .Error (1 )
17
+ }
18
+
19
+ func (m * MockDynamoDB ) PutItem (input * dynamodb.PutItemInput ) (* dynamodb.PutItemOutput , error ) {
20
+ args := m .Called (input )
21
+ return args .Get (0 ).(* dynamodb.PutItemOutput ), args .Error (1 )
22
+ }
23
+
24
+ func (m * MockDynamoDB ) Scan (input * dynamodb.ScanInput ) (* dynamodb.ScanOutput , error ) {
25
+ args := m .Called (input )
26
+ return args .Get (0 ).(* dynamodb.ScanOutput ), args .Error (1 )
27
+ }
28
+
29
+ func (m * MockDynamoDB ) GetItem (input * dynamodb.GetItemInput ) (* dynamodb.GetItemOutput , error ) {
30
+ args := m .Called (input )
31
+ return args .Get (0 ).(* dynamodb.GetItemOutput ), args .Error (1 )
32
+ }
Original file line number Diff line number Diff line change
1
+ package mocks
2
+
3
+ import "github.com/stretchr/testify/mock"
4
+
5
+ type MockJWTUtils struct {
6
+ mock.Mock
7
+ }
8
+
9
+ func (m * MockJWTUtils ) GenerateToken (userID string ) (string , error ) {
10
+ args := m .Called (userID )
11
+ return args .String (0 ), args .Error (1 )
12
+ }
Original file line number Diff line number Diff line change
1
+ package mocks
2
+
3
+ import "github.com/stretchr/testify/mock"
4
+
5
+ type MockPasswordHasher struct {
6
+ mock.Mock
7
+ }
8
+
9
+ func (m * MockPasswordHasher ) HashPassword (password string ) (string , error ) {
10
+ args := m .Called (password )
11
+ return args .String (0 ), args .Error (1 )
12
+ }
13
+
14
+ func (m * MockPasswordHasher ) ComparePassword (hashedPassword , password string ) error {
15
+ args := m .Called (hashedPassword , password )
16
+ return args .Error (0 )
17
+ }
Original file line number Diff line number Diff line change
1
+ package mocks
2
+
3
+ import (
4
+ "github.com/dieg0code/shared/models"
5
+ "github.com/stretchr/testify/mock"
6
+ )
7
+
8
+ type MockUserRepository struct {
9
+ mock.Mock
10
+ }
11
+
12
+ func (m * MockUserRepository ) GetByEmail (email string ) (models.User , error ) {
13
+ args := m .Called (email )
14
+ return args .Get (0 ).(models.User ), args .Error (1 )
15
+ }
16
+
17
+ func (m * MockUserRepository ) Create (user models.User ) (models.User , error ) {
18
+ args := m .Called (user )
19
+ return args .Get (0 ).(models.User ), args .Error (1 )
20
+ }
21
+
22
+ func (m * MockUserRepository ) GetAll () ([]models.User , error ) {
23
+ args := m .Called ()
24
+ return args .Get (0 ).([]models.User ), args .Error (1 )
25
+ }
26
+
27
+ func (m * MockUserRepository ) GetByID (userID string ) (models.User , error ) {
28
+ args := m .Called (userID )
29
+ return args .Get (0 ).(models.User ), args .Error (1 )
30
+ }
Original file line number Diff line number Diff line change
1
+ package mocks
2
+
3
+ import (
4
+ "github.com/dieg0code/shared/json/request"
5
+ "github.com/dieg0code/shared/json/response"
6
+ "github.com/dieg0code/shared/models"
7
+ "github.com/stretchr/testify/mock"
8
+ )
9
+
10
+ type MockUserService struct {
11
+ mock.Mock
12
+ }
13
+
14
+ func (m * MockUserService ) RegisterUser (createUserReq request.CreateUserRequest ) (models.User , error ) {
15
+ args := m .Called (createUserReq )
16
+ return args .Get (0 ).(models.User ), args .Error (1 )
17
+ }
18
+ func (m * MockUserService ) GetAllUsers () ([]response.UserResponse , error ) {
19
+ args := m .Called ()
20
+ return args .Get (0 ).([]response.UserResponse ), args .Error (1 )
21
+ }
22
+ func (m * MockUserService ) GetUserByID (id string ) (response.UserResponse , error ) {
23
+ args := m .Called (id )
24
+ return args .Get (0 ).(response.UserResponse ), args .Error (1 )
25
+ }
26
+ func (m * MockUserService ) LogInUser (logInUserReq request.LogInUserRequest ) (response.LogInUserResponse , error ) {
27
+ args := m .Called (logInUserReq )
28
+ return args .Get (0 ).(response.LogInUserResponse ), args .Error (1 )
29
+ }
You can’t perform that action at this time.
0 commit comments