Skip to content

Commit

Permalink
notification repo test
Browse files Browse the repository at this point in the history
  • Loading branch information
source-Alexander-Rudenko committed Dec 18, 2024
1 parent dc4e982 commit bf6e3f6
Show file tree
Hide file tree
Showing 3 changed files with 488 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ all: auth_service user_service event_service image_service notification_service

clean:
rm -rf $(BIN_DIR)

coverage:
go test $(go list ./... | grep -vE '/mocks|/docs|/vendor|/api|_easyjson.go') -coverprofile=coverage.out -coverpkg=$(go list ./... | grep -vE '/mocks|/vendor|/api|/docs|_easyjson.go' | tr '\n' ,) && go tool cover -func=coverage.out | grep total
go tool cover -func=coverage.out
16 changes: 12 additions & 4 deletions internal/notification/repository/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ package repository
import (
"context"
"fmt"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"

"kudago/internal/models"

"github.com/jackc/pgx/v5/pgxpool"
)

type NotificationDB struct {
pool *pgxpool.Pool
pool Pool
}

type Pool interface {
Begin(ctx context.Context) (pgx.Tx, error)
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
}

func NewDB(pool *pgxpool.Pool) *NotificationDB {
func NewDB(pool Pool) *NotificationDB {
return &NotificationDB{
pool: pool,
}
Expand Down
Loading

0 comments on commit bf6e3f6

Please sign in to comment.