pashagolub / pgxmock

pgx mock driver for golang to test database interactions
Other
393 stars 49 forks source link

Add BeginTx in pgxIface #47

Closed serhiy-v closed 2 years ago

serhiy-v commented 3 years ago

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?

pashagolub commented 3 years ago

Hi,

thanks for noticing. Yeap, this issue should be addressed. Seems like I just forgot to update the interface declaration.

avshvetz commented 2 years ago

Hi @pashagolub , I have the same issue. I've prepared PR, please let me know if I need to do additional changes https://github.com/pashagolub/pgxmock/pull/48