Skip to content

Commit

Permalink
lastest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJOSoderqvist committed Dec 18, 2024
1 parent f603644 commit 6199260
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- name: Get dependencies
run: go mod tidy

# - name: Run make test
# run: make test
- name: Run make test
run: make test

golangci:
name: go-lint
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- name: Get dependencies
run: go mod tidy

# - name: Run make test
# run: make test
- name: Run make test
run: make test

linter:
name: go-lint
Expand Down
9 changes: 0 additions & 9 deletions internal/delivery/category/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ type dtoCategory struct {
LinkTo string `json:"link_to"`
}

func toDtoCategory(category model.Category) dtoCategory {
return dtoCategory{
ID: category.ID,
Name: category.Name,
Picture: category.Picture,
LinkTo: category.LinkTo,
}
}

type dtoProductCatalog struct {
dtoProduct
ImageURL string `json:"image_url"`
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/orders/create_order_from_cart.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func (r *OrdersRepo) CreateOrderFromCart(ctx context.Context, orderData *order.O

defer func() {
if p := recover(); p != nil || err != nil {
tx.Rollback(ctx)
_ = tx.Rollback(ctx)
} else {
tx.Commit(ctx)
_ = tx.Commit(ctx)
}
}()

Expand Down
11 changes: 5 additions & 6 deletions internal/repository/orders/create_order_from_cart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func (suite *OrdersRepoSuite) SetupTest() {

orderID := uuid.New()
var userID uint32
faker.FakeData(&userID)
_ = faker.FakeData(&userID)

var id1, id2 uint32
faker.FakeData(&id1)
faker.FakeData(&id2)
_ = faker.FakeData(&id1)
_ = faker.FakeData(&id2)

var optionID uint32
faker.FakeData(&optionID)
_ = faker.FakeData(&optionID)
suite.order = &model.OrderFromCart{
OrderID: orderID,
UserID: userID,
Expand All @@ -53,9 +53,8 @@ func (suite *OrdersRepoSuite) SetupTest() {
}

func (suite *OrdersRepoSuite) TestCreateOrderFromCart() {
ctx := context.Background()
requestID := uuid.New()
ctx = context.WithValue(context.Background(), utils.RequestIDName, requestID)
ctx := context.WithValue(context.Background(), utils.RequestIDName, requestID)
suite.mock.ExpectBegin()

suite.mock.ExpectQuery(`INSERT INTO orders\s*\(id, user_id, total_price, address, created_at, updated_at\)\s*VALUES\s*\(\$1, \$2, \$3, \$4, NOW\(\), NOW\(\)\)\s*RETURNING created_at;`).
Expand Down
6 changes: 2 additions & 4 deletions internal/repository/orders/get_nearest_delivery_date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ func (suite *OrdersRepoGetNearestDeliveryDateSuite) SetupTest() {
}

func (suite *OrdersRepoGetNearestDeliveryDateSuite) TestGetNearestDeliveryDate_Success() {
ctx := context.Background()
requestID := uuid.New()
ctx = context.WithValue(context.Background(), utils.RequestIDName, requestID)
ctx := context.WithValue(context.Background(), utils.RequestIDName, requestID)
var userID uint32 = 12345

expectedDate := time.Now().Add(24 * time.Hour)
Expand All @@ -46,9 +45,8 @@ func (suite *OrdersRepoGetNearestDeliveryDateSuite) TestGetNearestDeliveryDate_S
}

func (suite *OrdersRepoGetNearestDeliveryDateSuite) TestGetNearestDeliveryDate_NoRows() {
ctx := context.Background()
requestID := uuid.New()
ctx = context.WithValue(context.Background(), utils.RequestIDName, requestID)
ctx := context.WithValue(context.Background(), utils.RequestIDName, requestID)
var userID uint32 = 12345

suite.mock.ExpectQuery(`SELECT MIN\(po.delivery_date\) FROM orders o JOIN product_orders po ON o.id = po.order_id WHERE o.user_id = \$1 AND po.delivery_date > NOW\(\);`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

var (
testContextRequestIDValue = uuid.New()
dbTestError = errors.New("ошибка базы данных")
)

const testContextRequestIDKey = "request-id"
Expand Down
1 change: 0 additions & 1 deletion internal/usecase/user/create_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

var (
testContextRequestIDValue = uuid.New()
dbTestError = errors.New("ошибка базы данных")
)

const testContextRequestIDKey = "request-id"
Expand Down
4 changes: 1 addition & 3 deletions internal/usecase/wish_list/copy_wishlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"github.com/go-park-mail-ru/2024_2_kotyari/internal/usecase/wish_list/mocks"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
"io"
Expand All @@ -13,8 +12,7 @@ import (
)

var (
returnsUUID = uuid.NewString()
e = errors.New("ошибка")
e = errors.New("ошибка")
)

func TestWishListUsecase_CopyWishList(t *testing.T) {
Expand Down

0 comments on commit 6199260

Please sign in to comment.