Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test a call to a procedure #327

Open
Kowiste opened this issue Nov 23, 2023 · 0 comments
Open

test a call to a procedure #327

Kowiste opened this issue Nov 23, 2023 · 0 comments

Comments

@Kowiste
Copy link

Kowiste commented Nov 23, 2023

I have to test one function where there is a call to a procedure like this

	if err = DB.WithContext(ctx).Raw("call x_get_number_by_id( ?)", id).Scan(&n).Error; err != nil {
		return n, err
	}

in the test i'm trying this

mockDB.ExpectExec("call x_get_number_by_id( ?)").WithArgs(2).WillReturnError(errors.New("test"))

and I have this error

2023/11/23 09:45:45 number.go:96 call to Query 'call x_get_number_by_id( ?)' with args [{Name: Ordinal:1 Value:2}], was not expected, next expectation is: ExpectedExec => expecting Exec or ExecContext which:
  - matches sql: 'call x_get_number_by_id( ?)'
  - is with arguments:
    0 - 2
  - should return error: 
[0.123ms] [rows:-] call x_get_number_by_id( 2)

There is not any other previous call to a database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant