-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
fix: make no argument passed validation opt-in #329
Conversation
@filikos @JessieAMorris could you kindly have a look at this PR? |
against := []driver.NamedValue{{Value: int64(5), Ordinal: 1}} | ||
if err := e.argsMatches(against); err == nil { | ||
t.Error("arguments should not match, since no expectation was set, but argument was passed") | ||
t.Error("arguments should not match, since argument was passed, but noArgs was set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the name noArgs
is internal, lets adjust the error msg: The users should know right away if WithoutArgs()
or WithArgs()
is being used correctly: Lets adjust the error to something like: received arguments *all arguments key+value* but expected no arguments. Expect the query to be
WithoutArgs()`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These particular test cases do not call WithoutArgs()
or WithArgs()
. Only the internal queryBasedExpectation
is manipulated to test the different behaviours.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyways, I will make a proposal to adjust many print statements since we can do some improvements on the UX of the library. Release will follow very soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…0346) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/DATA-DOG/go-sqlmock](https://togithub.com/DATA-DOG/go-sqlmock) | `v1.5.1` -> `v1.5.2` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.1/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.1/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>DATA-DOG/go-sqlmock (github.com/DATA-DOG/go-sqlmock)</summary> ### [`v1.5.2`](https://togithub.com/DATA-DOG/go-sqlmock/releases/tag/v1.5.2) [Compare Source](https://togithub.com/DATA-DOG/go-sqlmock/compare/v1.5.1...v1.5.2) #### What's Changed ##### Fixes breaking change from: [https://github.com/DATA-DOG/go-sqlmock/pull/295](https://togithub.com/DATA-DOG/go-sqlmock/pull/295) - fix: make no argument passed validation opt-in by [@​IvoGoman](https://togithub.com/IvoGoman) in [https://github.com/DATA-DOG/go-sqlmock/pull/329](https://togithub.com/DATA-DOG/go-sqlmock/pull/329) **Full Changelog**: DATA-DOG/go-sqlmock@v1.5.1...v1.5.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com> Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
…en-telemetry#30346) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/DATA-DOG/go-sqlmock](https://togithub.com/DATA-DOG/go-sqlmock) | `v1.5.1` -> `v1.5.2` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.1/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.1/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>DATA-DOG/go-sqlmock (github.com/DATA-DOG/go-sqlmock)</summary> ### [`v1.5.2`](https://togithub.com/DATA-DOG/go-sqlmock/releases/tag/v1.5.2) [Compare Source](https://togithub.com/DATA-DOG/go-sqlmock/compare/v1.5.1...v1.5.2) #### What's Changed ##### Fixes breaking change from: [https://github.com/DATA-DOG/go-sqlmock/pull/295](https://togithub.com/DATA-DOG/go-sqlmock/pull/295) - fix: make no argument passed validation opt-in by [@&open-telemetry#8203;IvoGoman](https://togithub.com/IvoGoman) in [https://github.com/DATA-DOG/go-sqlmock/pull/329](https://togithub.com/DATA-DOG/go-sqlmock/pull/329) **Full Changelog**: DATA-DOG/go-sqlmock@v1.5.1...v1.5.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com> Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/DATA-DOG/go-sqlmock](https://togithub.com/DATA-DOG/go-sqlmock) | `v1.5.0` -> `v1.5.2` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.0/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fDATA-DOG%2fgo-sqlmock/v1.5.0/v1.5.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>DATA-DOG/go-sqlmock (github.com/DATA-DOG/go-sqlmock)</summary> ### [`v1.5.2`](https://togithub.com/DATA-DOG/go-sqlmock/releases/tag/v1.5.2) [Compare Source](https://togithub.com/DATA-DOG/go-sqlmock/compare/v1.5.1...v1.5.2) #### What's Changed ##### Fixes breaking change from: [https://github.com/DATA-DOG/go-sqlmock/pull/295](https://togithub.com/DATA-DOG/go-sqlmock/pull/295) - fix: make no argument passed validation opt-in by [@​IvoGoman](https://togithub.com/IvoGoman) in [https://github.com/DATA-DOG/go-sqlmock/pull/329](https://togithub.com/DATA-DOG/go-sqlmock/pull/329) **Full Changelog**: DATA-DOG/go-sqlmock@v1.5.1...v1.5.2 ### [`v1.5.1`](https://togithub.com/DATA-DOG/go-sqlmock/releases/tag/v1.5.1) [Compare Source](https://togithub.com/DATA-DOG/go-sqlmock/compare/v1.5.0...v1.5.1) Release was tested & verified using [aws-sqk ](https://togithub.com/aws/aws-xray-sdk-go/pull/450) ##### What's Changed - Add go 1.15 in travis by [@​gold-kou](https://togithub.com/gold-kou) in [https://github.com/DATA-DOG/go-sqlmock/pull/234](https://togithub.com/DATA-DOG/go-sqlmock/pull/234) - Update code sample by [@​ashhadsheikh](https://togithub.com/ashhadsheikh) in [https://github.com/DATA-DOG/go-sqlmock/pull/244](https://togithub.com/DATA-DOG/go-sqlmock/pull/244) - Fix ExpectedExec Stringer implementation by [@​maguro](https://togithub.com/maguro) in [https://github.com/DATA-DOG/go-sqlmock/pull/249](https://togithub.com/DATA-DOG/go-sqlmock/pull/249) - Add Multi Row Support by [@​asahasrabuddhe](https://togithub.com/asahasrabuddhe) in [https://github.com/DATA-DOG/go-sqlmock/pull/263](https://togithub.com/DATA-DOG/go-sqlmock/pull/263) - Add Go 1.16 and 1.17 to Travis by [@​gliptak](https://togithub.com/gliptak) in [https://github.com/DATA-DOG/go-sqlmock/pull/279](https://togithub.com/DATA-DOG/go-sqlmock/pull/279) - fix package by [@​col3name](https://togithub.com/col3name) in [https://github.com/DATA-DOG/go-sqlmock/pull/284](https://togithub.com/DATA-DOG/go-sqlmock/pull/284) - \[Chore]: Add Issue Template by [@​Ghvstcode](https://togithub.com/Ghvstcode) in [https://github.com/DATA-DOG/go-sqlmock/pull/289](https://togithub.com/DATA-DOG/go-sqlmock/pull/289) - Fix args passed not exp by [@​IvoGoman](https://togithub.com/IvoGoman) in [https://github.com/DATA-DOG/go-sqlmock/pull/295](https://togithub.com/DATA-DOG/go-sqlmock/pull/295) - fixes csv parse errors being silently ignored by [@​IvoGoman](https://togithub.com/IvoGoman) in [https://github.com/DATA-DOG/go-sqlmock/pull/315](https://togithub.com/DATA-DOG/go-sqlmock/pull/315) - CSVColParser: correctly set nil values in Rows by [@​IvoGoman](https://togithub.com/IvoGoman) in [https://github.com/DATA-DOG/go-sqlmock/pull/318](https://togithub.com/DATA-DOG/go-sqlmock/pull/318) - Modify: existing panic in AddRow to give a hint to the issue by [@​co60ca](https://togithub.com/co60ca) in [https://github.com/DATA-DOG/go-sqlmock/pull/326](https://togithub.com/DATA-DOG/go-sqlmock/pull/326) ##### New Contributors - [@​gold-kou](https://togithub.com/gold-kou) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/234](https://togithub.com/DATA-DOG/go-sqlmock/pull/234) - [@​ashhadsheikh](https://togithub.com/ashhadsheikh) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/244](https://togithub.com/DATA-DOG/go-sqlmock/pull/244) - [@​maguro](https://togithub.com/maguro) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/249](https://togithub.com/DATA-DOG/go-sqlmock/pull/249) - [@​asahasrabuddhe](https://togithub.com/asahasrabuddhe) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/263](https://togithub.com/DATA-DOG/go-sqlmock/pull/263) - [@​col3name](https://togithub.com/col3name) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/284](https://togithub.com/DATA-DOG/go-sqlmock/pull/284) - [@​Ghvstcode](https://togithub.com/Ghvstcode) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/289](https://togithub.com/DATA-DOG/go-sqlmock/pull/289) - [@​IvoGoman](https://togithub.com/IvoGoman) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/295](https://togithub.com/DATA-DOG/go-sqlmock/pull/295) - [@​co60ca](https://togithub.com/co60ca) made their first contribution in [https://github.com/DATA-DOG/go-sqlmock/pull/326](https://togithub.com/DATA-DOG/go-sqlmock/pull/326) **Full Changelog**: DATA-DOG/go-sqlmock@v1.5.0...v1.5.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/PingCAP-QE/ee-apps). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44Ny4yIiwidXBkYXRlZEluVmVyIjoiMzcuMjAwLjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
#295 introduced stricter checking of query arguments. This results in new test failures when using e.g.
ExpectedQuery
orExpectedExec
withoutWithArgs(..)
and the actual query passes arguments. This case of no expected arguments but actual arguments passed was previously not caught.However, there is also the case where queries are matched via
QueryMatcherRegexp
and there is no intention to strictly validate the actual arguments. This case broke with the above mentioned change and requires rather cumbersome fixing as such:In order to allow for both strict and relaxed matching of the expectations this change adds
WithoutArgs()
. This new Method onExpectedQuery
andExpectedExec
allows to strictly ensure that the actual query does not pass any arguments.This reverts the strict argument checking introduced with #295 and makes this behavior opt-in.
Furthermore, a test will panic if both
WithArgs(..)
andWithoutArgs()
are used together.