pashagolub / pgxmock

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

Readme productID parameter type #37

Closed alifma closed 3 years ago

alifma commented 3 years ago

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

pashagolub commented 3 years ago

Hello,

what kind of error are you getting?

alifma commented 3 years ago

this is the console output, im running go 1.16 on ubuntu

=== RUN   TestShouldUpdateStats
    main_test.go:26: error was not expected while updating stats: ExecQuery 'INSERT INTO product_viewers (user_id, product_id) VALUES (?, ?)', arguments do not match: argument 0 expected [int - 2] does not match actual [int64 - 2]
    main_test.go:31: there were unfulfilled expectations: there is a remaining expectation which was not matched: ExpectedExec => expecting Exec or ExecContext which:
          - matches sql: 'INSERT INTO product_viewers'
          - is with arguments:
            0 - 2
            1 - 3
          - should return Result having:
              RowsAffected: 1
--- FAIL: TestShouldUpdateStats (0.00s)
=== RUN   TestShouldRollbackStatUpdatesOnFailure
    main_test.go:57: there were unfulfilled expectations: there is a remaining expectation which was not matched: ExpectedExec => expecting Exec or ExecContext which:
          - matches sql: 'INSERT INTO product_viewers'
          - is with arguments:
            0 - 2
            1 - 3
          - should return error: some error
--- FAIL: TestShouldRollbackStatUpdatesOnFailure (0.00s)
FAIL
exit status 1
FAIL    sqltest    0.003s
pashagolub commented 3 years ago

Oh, I see now. I was looking into examples here: https://github.com/pashagolub/pgxmock/blob/master/examples/basic/basic.go

Thanks, I'll update readme text.