From 37583a39d513834b0d0eb2d909ccc54f6df97bbf Mon Sep 17 00:00:00 2001 From: pshapovalov Date: Sun, 10 Mar 2024 15:36:36 +0300 Subject: [PATCH] feat: pgx mock added --- pkg/dbclient/mock/pgxmock.go | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 pkg/dbclient/mock/pgxmock.go diff --git a/pkg/dbclient/mock/pgxmock.go b/pkg/dbclient/mock/pgxmock.go new file mode 100644 index 0000000..780d867 --- /dev/null +++ b/pkg/dbclient/mock/pgxmock.go @@ -0,0 +1,62 @@ +package mock + +import ( + "context" + + "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgconn" +) + +type Pgtx struct{} + +// Conn implements pgx.Tx. +func (p *Pgtx) Conn() *pgx.Conn { + panic("unimplemented") +} + +// CopyFrom implements pgx.Tx. +func (p *Pgtx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) { + panic("unimplemented") +} + +// Exec implements pgx.Tx. +func (p *Pgtx) Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error) { + panic("unimplemented") +} + +// LargeObjects implements pgx.Tx. +func (p *Pgtx) LargeObjects() pgx.LargeObjects { + panic("unimplemented") +} + +// Prepare implements pgx.Tx. +func (p *Pgtx) Prepare(ctx context.Context, name string, sql string) (*pgconn.StatementDescription, error) { + panic("unimplemented") +} + +// Query implements pgx.Tx. +func (p *Pgtx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) { + panic("unimplemented") +} + +// QueryRow implements pgx.Tx. +func (p *Pgtx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row { + panic("unimplemented") +} + +// SendBatch implements pgx.Tx. +func (p *Pgtx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults { + panic("unimplemented") +} + +func (*Pgtx) Commit(context.Context) error { + return nil +} + +func (*Pgtx) Rollback(context.Context) error { + return nil +} + +func (*Pgtx) Begin(context.Context) (pgx.Tx, error) { + return &Pgtx{}, nil +} \ No newline at end of file