-
Notifications
You must be signed in to change notification settings - Fork 8
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
Stubbing only ever attempts to match against the first entry in the plan #18
Comments
It appears that in both #17 and #18 I've fundamentally misunderstood how stubbing is supposed to work. Each entry in the plan is an expected invocation, not a list of possible invocations to expect. I'm happy for both issues to be closed, but it would be nice if there was a way to support this kind of functionality - instead of listing out all invocations in order, it would be helpful if we could list prefixes for expected invocations (from most specific to least specific) and match against all of them every time. Right now it isn't clear to me why it bothers performing any argument matching at all, given it expects each pattern to be used only once. It's especially not clear to me what the behaviour is when only one pattern is supplied. |
Okay so I'm fundamentally confused about how stubbing is supposed to work. For most of my tests, I have However for some of my tests, I know that aws-cli will be run twice, and I need it to behave differently in this situation, based on the arguments its passed. Therefore I first need to run However this doesn't work. For reasons I cannot fathom, it tells me the stub doesn't exist. I added this debugging code before my
It still tells me the stub doesn't exist, even though I can see the file on disk. I have no idea why this "file exists" check isn't passing: Even if the "file exists" check was passing, it looks like there is code in the stubber to check whether or not the stub was used at all: So I'm not sure what options I have here. I can make assumptions about the internal implementation details of the stubber by manually deleting the files it's looking for that |
It looks like it just silently returns an exit status of Would it be possible to at least emit a warning in this case that shows up even if the test was successfully run? I'm not sure I would have ever had any idea that some of my tests weren't behaving the way I expected if I hadn't looked so deeply into the stubber for this issue. |
I think this
break
statement is preventing the stubber from matching on anything except the first entry in the plan:https://github.com/buildkite-plugins/bats-mock/blob/master/binstub#L112
It always exits the loop, even if there are more entries in the plan :(
The text was updated successfully, but these errors were encountered: