From 042191aa7fd0fe9e3ade39f15902e5f48d40d2fa Mon Sep 17 00:00:00 2001 From: Asman Mamou Date: Fri, 20 Dec 2024 22:11:47 +0300 Subject: [PATCH] another resolve --- .../repository/ads_repository_test.go | 67 ------------------- 1 file changed, 67 deletions(-) diff --git a/microservices/ads_service/repository/ads_repository_test.go b/microservices/ads_service/repository/ads_repository_test.go index fd2ba18..bab3a47 100644 --- a/microservices/ads_service/repository/ads_repository_test.go +++ b/microservices/ads_service/repository/ads_repository_test.go @@ -655,73 +655,6 @@ func TestUpdatePlace_UserNotAuthorized(t *testing.T) { assert.NoError(t, err) } -func TestDeletePlace(t *testing.T) { - if err := logger.InitLoggers(); err != nil { - log.Fatalf("Failed to initialize loggers: %v", err) - } - defer func() { - err := logger.SyncLoggers() - if err != nil { - return - } - }() - - db, mock, err := setupDBMock() - assert.Nil(t, err) - - adRepo := NewAdRepository(db) - ctx := context.Background() - - adId := "1" - userId := "123" - - mock.ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "ads" WHERE uuid = $1 ORDER BY "ads"."uuid" LIMIT $2`)). - WithArgs(adId, 1). - WillReturnRows(sqlmock.NewRows([]string{"uuid", "address", "authorUUID"}). - AddRow("1", "test_address", "123")) - - mock.ExpectBegin() - mock.ExpectExec(regexp.QuoteMeta(`DELETE FROM "images" WHERE "adId" = $1`)). - WithArgs(adId). - WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectCommit() - - mock.ExpectBegin() - mock.ExpectExec(regexp.QuoteMeta(`DELETE FROM "ad_positions" WHERE "adId" = $1`)). - WithArgs(adId). - WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectCommit() - - mock.ExpectBegin() - mock.ExpectExec(regexp.QuoteMeta(`DELETE FROM "ad_available_dates" WHERE "adId" = $1`)). - WithArgs(adId). - WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectCommit() - - mock.ExpectBegin() - mock.ExpectExec(regexp.QuoteMeta(`DELETE FROM "ad_rooms" WHERE "adId" = $1`)). - WithArgs(adId). - WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectCommit() - - mock.ExpectBegin() - mock.ExpectExec(regexp.QuoteMeta(`DELETE FROM "requests" WHERE "adId" = $1`)). - WithArgs(adId). - WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectCommit() - - mock.ExpectBegin() - mock.ExpectExec(regexp.QuoteMeta(`DELETE FROM "ads" WHERE "ads"."uuid" = $1`)). - WithArgs(adId). - WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectCommit() - - err = adRepo.DeletePlace(ctx, adId, userId) - - assert.NoError(t, err) - assert.NoError(t, mock.ExpectationsWereMet()) -} - func TestDeletePlace_Failure(t *testing.T) { if err := logger.InitLoggers(); err != nil { log.Fatalf("Failed to initialize loggers: %v", err)