Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMaster482 committed Dec 14, 2023
1 parent 7987d8d commit 1fef37e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *AuthRep) GetUserByLogin(ctx context.Context, login string) (*models.Use

if err != nil {
if errors.Is(err, pg.ErrNoRows) {
return nil, fmt.Errorf("[repo] %w: %v", &models.NoSuchUserError{}, err)
return nil, fmt.Errorf("[repo] %w, %v", &models.NoSuchUserError{}, err)
} else {
return nil, fmt.Errorf("[repo] failed request db: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/go-park-mail-ru/2023_2_Hamster/internal/models"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
"github.com/jackc/pgx/v4"
"github.com/pashagolub/pgxmock"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -100,15 +101,15 @@ func TestGetUserByLogin(t *testing.T) {
{
name: "UserNotFound",
rows: pgxmock.NewRows([]string{"id", "login", "username", "password", "planned_budget", "avatar_url"}),
rowsErr: sql.ErrNoRows,
err: fmt.Errorf("[repo] %w, %v", &models.NoSuchUserError{}, sql.ErrNoRows),
rowsErr: pgx.ErrNoRows,
err: fmt.Errorf("[repo] %w, %v", &models.NoSuchUserError{}, pgx.ErrNoRows),
expected: nil,
},
{
name: "DatabaseError",
rows: pgxmock.NewRows([]string{"id", "login", "username", "password", "planned_budget", "avatar_url"}),
rowsErr: errors.New("database error"),
err: fmt.Errorf("[repo] failed request db %w", errors.New("database error")),
err: fmt.Errorf("[repo] failed request db: %w", errors.New("database error")),
expected: nil,
},
}
Expand Down

0 comments on commit 1fef37e

Please sign in to comment.