Skip to content

Commit

Permalink
feat: pgx mock added
Browse files Browse the repository at this point in the history
  • Loading branch information
pshapovalov committed Mar 10, 2024
1 parent e5ead01 commit 37583a3
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions pkg/dbclient/mock/pgxmock.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 37583a3

Please sign in to comment.