-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added complete create product with injection missing unit testing
- Loading branch information
Showing
15 changed files
with
169 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
package mocks | ||
|
||
import "github.com/sebajax/go-vertical-slice-architecture/internal/user" | ||
import ( | ||
"time" | ||
|
||
type mockUserRepository struct{} | ||
"github.com/sebajax/go-vertical-slice-architecture/internal/product" | ||
) | ||
|
||
func NewMockUserRepository() user.UserRepository { | ||
return &mockUserRepository{} | ||
type mockProductRepository struct{} | ||
|
||
func NewMockProductRepository() product.ProductRepository { | ||
return &mockProductRepository{} | ||
} | ||
|
||
func (mock *mockUserRepository) Save(u *user.User) (int64, error) { | ||
func (mock *mockProductRepository) Save(p *product.Product) (int64, error) { | ||
return 1, nil | ||
} | ||
|
||
func (mock *mockUserRepository) GetByEmail(email string) (*user.User, bool, error) { | ||
/*return &user.User{ | ||
Id: 1, | ||
Email: "[email protected]", | ||
Name: "Juan", | ||
DateOfBirth: time.Now(), | ||
func (mock *mockProductRepository) GetBySku(email string) (*product.Product, bool, error) { | ||
return &product.Product{ | ||
Id: 1, | ||
Name: "ps5", | ||
Sku: "123456sony", | ||
Category: product.SmartWatch, | ||
Price: 300.00, | ||
CreatedAt: time.Now(), | ||
}, true, nil*/ | ||
return nil, true, nil | ||
}, true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package product | ||
|
||
// User port interface definition for depedency injection | ||
type UserRepository interface { | ||
Save(u *User) (int64, error) | ||
GetByEmail(email string) (*User, bool, error) | ||
// Product port interface definition for depedency injection | ||
type ProductRepository interface { | ||
Save(p *Product) (int64, error) | ||
GetBySku(sku string) (*Product, bool, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.