Coder Social home page Coder Social logo

pgxmock's Introduction

Hi there 👋

pavlogolub=# SELECT * FROM pg_settings;

name         |                                setting
--------------------------------------------------------------------------------------
Name         | Pavlo Golub
IPA          | [pɐu̯ˈɫɔ ˈɦɔɫʊb]
Height       | 202cm
Weight       | NaN
Origin       | Kropyvnytskyi, UA
Location     | Bratislava, SK
Career       | [2002,)
Work         | Cybertec PostgreSQL International
Community    | {PostgreSQL Ukraine co-founder, GSoC PostgreSQL Org Admin}
Social       | {Blog, Facebook, LinkedIn, Bluesky, Mastodon, Twitter, PostgreSQL.Life, Stack Overflow, Sessionize}
Invaders     | Must Die!
Слава        | Україні!🇺🇦

pgxmock's People

Contributors

2tvenom avatar adewaleafolabi avatar dependabot-preview[bot] avatar dependabot[bot] avatar dragonfriend0013 avatar eklmv avatar jsnb-devoted avatar juneezee avatar labi-le avatar massinja avatar mynyml avatar nickbelhomme avatar pashagolub avatar peano88 avatar sdblackwood avatar sejin-p avatar svennis94 avatar sweep-ai[bot] avatar tobicatobi avatar tulioguaraldob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pgxmock's Issues

Unable to scan to uint64 or other standard base types

Describe the bug

It seems the mock system fails to scan to base types if the Scan() doesn't return the exact type as the destination value. For example, this query returns a int, but while it can convert to uint it seems the Scan() can't convert it. I'd expect this for custom types, but not base types. Could you put me in the right direction to fix this?

The code causing the issue is here.

I've created the following test:

func TestThisStrangeIssue(t *testing.T) {
	mock, err := pgxmock.NewPool()
	if err != nil {
		panic(err)
	}

	mock.ExpectQuery("SELECT .+ FROM test WHERE .+").
		WithArgs(1).
		WillReturnRows(pgxmock.NewRows(
			[]string{"id"}).
			AddRow(1),
		)

	rows := mock.QueryRow(context.Background(), "SELECT id FROM test WHERE id = $1", 1)

	var id uint64
	err = rows.Scan(&id)
	if err != nil {
		t.Error(err)
	}
}

Which returns:

--- FAIL: TestThisStrangeIssue (0.00s)
    /~/hello_test.go:65: Destination kind 'uint64' not supported for value kind 'int' of column 'id'

Readme productID parameter type

Describe the bug
i think the code sample on readme need some adjustment

To Reproduce

func recordStats(db PgxIface, userID, productID int64) (err error) {
}

productID parameter type should be int, but its written as int64 so the code wont run on my devices

pgpool.Acquire() method

Hi, When the pgpool.Adquire() will be implemented?

This is the current code

func (p *pgxmockPool) Acquire(ctx context.Context) (*pgxpool.Conn, error) {
	return nil, errors.New("pgpool.Acquire() method is not implemented")
}

I need that method to test pg pool connections.

Incompatibility with sqlmock

Is your feature request related to a problem? Please describe.

sqlmock does some value conversions for the user, for example:

  • Scanned *float64 from float64 value supplied in AddRow()
  • Scanned []byte from string value supplied in AddRow()

pgxmock is more strict, not supporting any "obvious" conversions.

PgConn method

Is your feature request related to a problem? Please describe.
Very similar to: #85
We use the PgConn method so it has to be included in our interface. Without that method being implemented we can't use the pgxmock conn

Describe the solution you'd like
Adding a stub for the method until someone actually needs to testing something with it.

Describe alternatives you've considered
I opened a PR and tested it out in our repo:
#87
Got a simple test passing

Additional context
Add any other context or screenshots about the feature request here.

Implement CopyFrom using pgxmock

This is more a question. I could not find any working example of how to test CopyFrom command using pgxmock. Is it possible? If so is there some example of how to do it?

PgxPoolIface is missing AcquireAllIdle

Is your feature request related to a problem? Please describe.

I needed to create a mock pool, on which a function calls pool.AcquireAllIdle(). That function is a custom implementation for pool.Reset(), which exists in pgx v3 and v5, but is missing in v4.

Describe the solution you'd like

Add the method to the PgxPoolIface

Describe alternatives you've considered

Hand-write a mock for that test case.

Additional context
Add any other context or screenshots about the feature request here.

Transactions and rollbacks after commits

Is your feature request related to a problem? Please describe.
When we need to mock transactions made with BeginFunc, we should mock rollback after commit:

		conn.ExpectBegin()
		conn.ExpectExec("DELETE FROM table WHERE id = $1").
			WithArgs(123).
			WillReturnResult(pgxmock.NewResult("DELETE", 1))
		conn.ExpectCommit()
		conn.ExpectRollback()

If we don't do this, we will receive should be nil, "all expectations were already fulfilled, call to Rollback transaction was not expected" given. Is it correct way to avoid this error?

Error: Query: could not match actual sql

Hello, I raised a question about this in #51 (reply in thread), but am still encountering this error in another environment.

This is in the test I've written

ctx := context.Background()

pool, err := pgxmock.NewPool()
if err != nil {
	t.Fatalf("error creating mock db: %v", err)
}

sql := `
	SELECT acct_status
	FROM ccm.cc_account_mx
	WHERE acct_uuid = $1;
`
cols := []string{"acct_status"}
rows := pgxmock.NewRows(cols)

pool.ExpectQuery(sql).WillReturnRows(rows)

event := events.APIGatewayProxyRequest{
	QueryStringParameters: map[string]string{"acct_uuid": "889eba15-a551-4528-a2ff-b117b06db5cf"},
}

handler := accounts.AccountGet(pool)

res, err := handler(ctx, event)

And within my function the result of pgxmockPool.QueryRow().Scan() is "SELECT acct_status FROM ccm.cc_account_mx WHERE acct_uuid = $1;" with expected regexp "SELECT acct_status FROM ccm.cc_account_mx WHERE acct_uuid = $1;"

It seems to me that these two SQL strings should match, and do match, so I do not understand how this error is happening.

Support for QueryFunc, BeginFunc, and BeginTxFunc

First of all, thanks for making this package.

Is your feature request related to a problem? Please describe.
pgx has added QueryFunc, BeginFunc, and BeginTxFunc to simplify operations and error handling (see pgx#821). I'm currently refactoring some of my code from Query to QueryFunc but ExpectQuery does not work for QueryFunc.

Describe the solution you'd like
ExpectQuery should support QueryFunc, and ExpectBegin should support BeginFunc and BeginTxFunc.

Describe alternatives you've considered
N/A

Additional context
Correct me if I am wrong, it seems like BeginTx is not supported as well because the pgxIFace interface does not include the BeginTx method.

type pgxIface interface {
	pgxMockIface
	Begin(context.Context) (pgx.Tx, error)
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	Ping(context.Context) error
	Prepare(context.Context, string, string) (*pgconn.StatementDescription, error)
	Deallocate(ctx context.Context, name string) error
}

Fix orders example TestShouldRefundUserWhenOrderIsCancelled() method

=== RUN   TestShouldRefundUserWhenOrderIsCancelled
   ..\pgxmock\examples\orders\orders_test.go:73: Expected no error, but got ExecQuery: could not match actual sql: "balance_stmt" with expected regexp "UPDATE users SET balance" instead
    ..\pgxmock\examples\orders\orders_test.go:77: there were unfulfilled expectations: there is a remaining expectation which was not matched: ExpectedExec => expecting Exec or ExecContext which:
          - matches sql: 'UPDATE users SET balance'
          - is with arguments:
            0 - 29
            1 - 2
          - should return Result having:
              RowsAffected: 1
--- FAIL: TestShouldRefundUserWhenOrderIsCancelled (0.00s)
FAIL
coverage: 39.2% of statements
FAIL	github.com/pashagolub/pgxmock/examples/orders	0.063s

QueryRow produces access violation

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x580f16]

need help

Hello, pashagolub
If may i ask about pgxmock, i've using it in journey of learning golang

This is my repository.go

type propinsiRepository struct {
	DB *pgx.Conn
}

func NewPropinsiRepository(db *pgx.Conn) PropinsiRepository {
	return &propinsiRepository{DB: db}
}


func (pr *propinsiRepository) FindById(Id int) (*Propinsi, error) {
	var p *Propinsi
	query := pr.DB.QueryRow(context.Background(), "SELECT propinsi_id, propinsi_nama FROM mst.propinsi WHERE propinsi_id=$1", Id)
	if err := query.Scan(&p.PropinsiId, &p.PropinsiNama); err != nil {
		return nil, err
	}
	return p, nil
}

and this is repository_test.go


func TestFindById(t *testing.T) {
	mock, err := pgxmock.NewConn()
	if err != nil {
		t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
	}
	defer mock.Close(context.Background())
	rows := mock.NewRows([]string{"propinsi_id", "propinsi_nama"}).AddRow(1, "test_propinsi_nama")
	query := "SELECT propinsi_id, propinsi_nama FROM mst.propinsi WHERE propinsi_id=\\?"
	propinsiID := int(1)
	mock.ExpectQuery(query).WithArgs(propinsiID).WillReturnRows(rows)
	repo := repository.NewPropinsiRepository(mock.Conn())
	anPropinsi, err := repo.FindById(propinsiID)
	assert.NoError(t, err)
	assert.NotNil(t, anPropinsi)
}

There is no error warning, when i inject mock.Conn() on NewPropinsiRepository, but when i try to test, there is an error occured

panic: Conn() is not available in pgxmock [recovered]
	panic: Conn() is not available in pgxmock

i'm still new in golang, and i'm so thankful for your support.

Starting using pgxmock

Hi, I just started to use pgxmock to write my unit tests, but I don't really understand how I can test these two
kind of queries:

  1. "CREATE TABLE foo(id serial, bar int) IF NOT EXISTS"
  2. "INSERT INTO foo(bar) VALUES (1) RETURNING id"

For the first one, my test always pass. For the later one, it always fails (I think the issue here is that I don't know the id before the insert so I don't know how can be compared).

Thanks

Fix Prepare expectations handling

pgx doesn't use statement conception executing prepared queries. Instead, every Query and Exec methods can accept prepared statement name instead of SQL.

pgxmock.NewPool and empty result set: runtime error: index out of range [0] with length 0

Describe the bug
When testing results sets with NO rows we get an out of range error.

To Reproduce
This should also happen in the blog api example.
https://github.com/pashagolub/pgxmock/blob/master/examples/blog/blog_test.go#L120

What I do is:
mockRead.ExpectQuery(".*").WillReturnRows(pgxmock.NewRows([]string{"value"}))

This produces the error on line:
https://github.com/pashagolub/pgxmock/blob/master/rows.go#L72

Current result set value:
2022-06-03_10-12

Expected behavior
it should just accept that there are no rows, and continue.

version: V1.6.0

Deadlock if BeginTx called with unexpected options

Describe the bug
If BeginTx (or BeginTxFunc) is called with unexpected options, ExpectationsWereMet deadlocks if called afterwards.

To Reproduce
In the example use db.BeginTx(context.Background(), pgx.TxOptions{IsoLevel: pgx.Serializable}) instead of db.Begin (requires adding BeginTx(context.Context, pgx.TxOptions) (pgx.Tx, error) to the PgxIface). Run tests.

Expected behavior
Error return from ExpectationsWereMet

Additional context
The problem seems to be here:

pgxmock/pgxmock.go

Lines 513 to 517 in ed5a923

if expected.opts != txOptions {
return nil, fmt.Errorf("Begin: call with transaction options '%v' was not expected, expected name is '%v'", txOptions, expected.opts)
}
expected.triggered = true
expected.Unlock()

Here expected.Unlock() is not called if expected.opts != txOptions.

Add support for `ConnInfo`

Is your feature request related to a problem? Please describe.
We are developing an app that uses ConnInfo method in pgx (link). We have our own interface for mocking but we want to move to pgxmock the issue I'm running into now is that our interface isn't compatible because the pgxIface is missing the ConnInfo method:

cannot use mock (variable of type pgxmock.PgxConnIface) as DBConn value in argument to getAllTables: pgxmock.PgxConnIface does not implement DBConn (missing method ConnInfo)

Describe the solution you'd like
Add the ConnInfo method to the interface if that is sensible/backwards compatible.

Describe alternatives you've considered
We are effectively doing the alternative by having our own interface but we are missing all the great unit testing functionality in pgxmock that we would like to use.

Additional context
I'll submit a naive PR for this. I suspect adding this could cause issues for current users of the package. I'm newer to go package development.

Support for JSONB

Is your feature request related to a problem? Please describe.
I have a jsonb column that pgx supports out of the box. However there's no way I know of to tell pgxmock that a value in AddRow() is of type json/jsonb. I tried wrapping it with pgtype.JSONB without success (got panic: reflect.Set: value of type pgtype.JSONB is not assignable to type Config).

Describe the solution you'd like
Built-in support for json/jsonb columns.

It might well be the case that there's already a known alternative for this, in which case the feature request would be to add it to the documentation for this project.

Implements Value() for *rowSets

Is your feature request related to a problem? Please describe.
Every time I need to use Values(), I need to override this method which is painful. The current implementation only returns nil, nil. So when I need to use the values, from a row, I have to create a new type and override the method returning a slice with the values.

Describe the solution you'd like
An implementation of Value method that allows the user to return a []interface{} with the values of a row.

Describe alternatives you've considered
As mentioned, the override is an alternative, but in order to it works, I have to create new types and my test file is huge due to this several changes.

Additional context
Currently, the method Values() (https://github.com/pashagolub/pgxmock/blob/master/rows.go#L60) is returning (no matter what) nil,nil. It could return the slice with the row values in it (just as the real pgx4 implementation does).

Fix TestShouldNotCancelOrderWithNonPendingStatus

--- FAIL: TestShouldNotCancelOrderWithNonPendingStatus (0.00s)
    orders_test.go:34: Expected no error, but got call to Prepare statement with query 
'UPDATE users SET balance = balance + ? WHERE id = ?', was not expected, next expectation is:
 ExpectedRollback => expecting transaction Rollback instead

Documentation Request: Differences from DATA-DOG/go-sqlmock?

Hello!
We are currently using DATA-DOG/go-sqlmock for Go applications that connect to PostgreSQL database via pgx. I noticed this library was forked from go-sqlmock, but I'm not quite sure when it was forked, nor what was changed in either library happened in the meantime. I noticed pgxmock is missing column.go so maybe Column Metadata was merged in sqlmock after this forked? However, statement.go is also missing, but probably that file was deliberately deleted?

I think pgxmock implements some new pgx-specific methods like:

	ExpectBeginTx(txOptions pgx.TxOptions) *ExpectedBegin
	ExpectCopyFrom(expectedTableName string, expectedColumns []string) *ExpectedCopyFrom
	NewRowsWithColumnDefinition(columns ...pgproto3.FieldDescription) *Rows
	NewColumn(name string) *pgproto3.FieldDescription

Are there any other features added to pgxmock that I should be aware of?

Error `Destination kind 'interface' not supported for value kind '<int64>' of column '<column>'`

Describe the bug
Cannot use *interface{} as type to use in Scan when use pgxmock, this results in the error below:

Destination kind 'interface' not supported for value kind '<int64>' of column '<column>'

To Reproduce
Some code snippets to reproduce the behavior:

If you have (like I have) an implementation which uses a variable with type *interface{} to scan a values.

var value any
err = r.QueryRow(ctx, q, args...).Scan(&value)
if err != nil {
   return
}

usage of pgxmock

mock.ExpectQuery(`SELECT 123`).
	WillReturnRows(
		mock.NewRows([]string{"id"}).
			AddRow(int64(123)))  // Value which should be scanned in *interface{}

Expected behavior
interface should contain the value of type int64 containing 123 without an error being throwed.

I think the following line plays a role in the behavior:

LINE 86: if destVal.Elem().Kind() == val.Kind() {

If the condition in this line is false, a last step is done to trying to use the Scanner interface (which *interface{} does not have), subsequently the error is triggered.

When looking at how the standard library deals with this with a type switch (database/sql/convert.go).
See specifically the last case where *any/*interface{} is dealt with. This logic is part of the convertAssignRows function.

Do you have any specific ideas on how to handle *interface{}?

        switch d := dest.(type) {
	case *string:
		sv = reflect.ValueOf(src)
		switch sv.Kind() {
		case reflect.Bool,
			reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
			reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
			reflect.Float32, reflect.Float64:
			*d = asString(src)
			return nil
		}
	case *[]byte:
		sv = reflect.ValueOf(src)
		if b, ok := asBytes(nil, sv); ok {
			*d = b
			return nil
		}
	case *RawBytes:
		sv = reflect.ValueOf(src)
		if b, ok := asBytes([]byte(*d)[:0], sv); ok {
			*d = RawBytes(b)
			return nil
		}
	case *bool:
		bv, err := driver.Bool.ConvertValue(src)
		if err == nil {
			*d = bv.(bool)
		}
		return err
	case *any:
		*d = src
		return nil
	}

Additional context
Both pgx (see: jackc/pgx#769) and https://github.com/DATA-DOG/go-sqlmock support this behavior.

invalid memory address when mock a call which use pgx.Conn?

I have the following funtion:

func GetUserByID(ctx context.Context, db *pgx.Conn, id int64) (*User, error) {
	var user User
	sql, args, err := sq.Select("id, userid, name, email").
		From("user").
		Where(sq.Eq{"id": id}).
		PlaceholderFormat(sq.Dollar).
		ToSql()
	if err != nil {
		return nil, err
	}
	err = db.QueryRow(ctx, sql, args...).Scan(&user.ID, &user.Userid, &user.Name, &user.Email)
	if err != nil {
		return nil, err
	}
	fmt.Println("Get User by ID")
	return &user, nil
}

Now I want to mock the call with:

mock, err := pgxmock.NewConn(pgxmock.QueryMatcherOption(pgxmock.QueryMatcherEqual))
if err != nil {
	t.Fatalf("an error '%s' was not expected when opening a stub database connection", err)
}
defer mock.Close(context.Background())
userid, _ := uuid.NewV4()
rows := pgxmock.NewRows([]string{"id", "userid", "name", "email"}).
	AddRow(int64(17), userid, "Testuser", "[email protected]")
mock.ExpectBegin()
mock.ExpectQuery("SELECT id, userid, name, email FROM user WHERE id = $1").
	WithArgs(int64(17)).
	WillReturnRows(rows).
	WillReturnError(nil)
mock.ExpectCommit()
result, err := GetUserByID(context.Background(), mock.Conn(), 17)
require.NoError(t, err)

But when I run the test I got the following error:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0xaa9cc9]

How can I mock the call without using a transaction? It's only a SELECT, so I do not need a transaction.

Thanks

Support for `SendBatch`

Is your feature request related to a problem? Please describe.
Missing functionality in mock: SendBatch currently just returns a nil object see here. This does not allow for mocking or testing inputs.

Describe the solution you'd like
Implement SendBatch on basic connection and pools. Additionally, create a mock.ExpectSendBatch function to test SendBatch calls in code.

Describe alternatives you've considered
Considering changing my code to not use SendBatch just to be able to better test expectations.

Additional context
None

Help with mocking returning pgx.Row from QueryRow method

We are using separate database connections for read and write proxies, so I've created a DBConnector interface and a struct that implements it that look like this:

type DBConnector interface {
	Begin(ctx context.Context) (pgx.Tx, error)
	BeginFunc(ctx context.Context, f func(pgx.Tx) error) error
	CloseConnection()
	Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) (pgx.Row, error)
	NewConnection(ctx context.Context, dp DBProxies) error
}

type AWSDB struct {
	reader *pgxpool.Pool
	writer *pgxpool.Pool
}

The AWSBD struct has methods like this to wrap the pgxpool.Pool methods using the intended reader or writer connection.

// QueryRow wraps the *pgxpool.Pool QueryRow method using the AWSDB reader connection
func (d *AWSDB) QueryRow(ctx context.Context, sql string, args ...interface{}) (pgx.Row, error) {
	if d.reader == nil {
		return nil, errors.New("reader pool not created")
	}

	return d.reader.QueryRow(ctx, sql, args...), nil
}

And so some code that implements this would look like this:

func getUserData(ctx context.Context, dbc db.DBConnector, c string) (row, error) {
	query := `
	SELECT
		ap.external_acct_id as external_acct_id,
		apt.user_status as user_status,
		ap.acct_uuid as acct_uuid,
		ap.user_id as user_id
	FROM account_profile ap
	JOIN app_user_type apt ON apt.user_id = ap.user_id
	WHERE ap.id = $1;
	`

	pgRow, err := dbc.QueryRow(ctx, query, c)
	if err != nil {
		return row{}, err
	}

	var r row
	if err := pgRow.Scan(
		&r.ExternalAcctID,
		&r.UserStatus,
		&r.AcctUUID,
		&r.UserID,
	); err != nil {
		if errors.Is(err, pgx.ErrNoRows) {
			return row{}, errors.New("no user found with id " + c)
		} else {
			return row{}, err
		}
	}

	return r, nil
}

I'd like to be able to write unit tests around this getUserData function to check responses for things like no rows found, etc. My approach has been to create a mock db connection that implements my db.DBConnector interface like this:

type mockAWSDB struct {
	db.DBConnector
	reader pgxmock.PgxPoolIface
}

func (md *mockAWSDB) NewConnection(ctx context.Context, dp db.DBProxies) error {
	pool, err := pgxmock.NewPool()
	if err != nil {
		return err
	}

	switch dp {
	case db.Read:
		md.reader = pool
	default:
		return fmt.Errorf("db proxy " + string(db.Read) + " only supported")
	}

	return nil
}


// This is where I'd like to create the mock `pgx.Row` value to return expected values
func (md *mockAWSDB) QueryRow(ctx context.Context, sql string, args ...interface{}) (pgx.Row, error) {

}

I'm falling short here and don't know how to make this QueryRow method to return the pgx.Row value that I want using the underlying pgxmock.PgxPoolIface QueryRow method. Any help would be appreciated, thanks.

Support CopyTo

Is your feature request related to a problem? Please describe.
Currently there is support for CopyFrom but no support for CopyTo

Describe the solution you'd like
Allow an expectation for the CopyTo function

Describe alternatives you've considered
N/A

Additional context
N/A

I'm happy to provide a PR for this.

pgxmock doesn't support scanning nullables

Describe the bug
SQL column values can be null. pgx/v4 supports this by having custom nullable structs, or scanning into pointers: https://pkg.go.dev/github.com/jackc/pgx#hdr-Null_Mapping. pgxmock can't test code that has to read and handle nulls because it does a strict type comparison.

To Reproduce
Here's a sample repo showing the issue, just clone and run make test to get this error:

--- FAIL: TestReadFromDatabase (0.00s)
    main_test.go:31: error: Destination kind 'ptr' not supported for value kind 'int' of column 'null_column'
FAIL
exit status 1
FAIL    github.com/OiCMudkips/pgxmockNullables  0.158s

Expected behavior
I would expect the test to not fail.

Screenshots
IMO N/A

Additional context
I will work on a PR to fix this this weekend, but initial guidance would be appreciated!

Add BeginTx in pgxIface

Hi, my code is using BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) function, and i can't use mock with it, because this func is not implemented in pgxIface. While exploring code of pgxmock I find out that function BeginTx is already exist:

func (c *pgxmock) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error) {
	ex, err := c.begin(txOptions)
	if ex != nil {
		time.Sleep(ex.delay)
	}
	if err != nil {
		return nil, err
	}

	return c, nil
}

Is it ok that this func is not implemented in pgxIface? Or maybe there is some other way of working with this func?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.