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

Stub fails to recognise call when arguments contain an asterisk character #7

Open
tommarshall opened this issue Mar 24, 2017 · 1 comment · May be fixed by #8
Open

Stub fails to recognise call when arguments contain an asterisk character #7

tommarshall opened this issue Mar 24, 2017 · 1 comment · May be fixed by #8

Comments

@tommarshall
Copy link

If the arguments string includes an asterisk then the bats-mock stub appears to fail to recognise the call.

Reduced test case:

#!/usr/bin/env bats

load '../vendor/bats-mock/stub'

teardown() {
  unstub aws
}

# fails
@test "test with asterisk" {
  stub aws \
    "ec2 describe-snapshots --query Snapshots[*].{Time:StartTime} : echo 'foo'"

  run aws ec2 describe-snapshots --query Snapshots[*].{Time:StartTime}
  [ "$output" = "foo" ]
}

# passes
@test "test without asterisk" {
  stub aws \
    "ec2 describe-snapshots --query Snapshots[].{Time:StartTime} : echo 'foo'"

  run aws ec2 describe-snapshots --query Snapshots[].{Time:StartTime}
  [ "$output" = "foo" ]
}

Output:

$ vendor/bats/bin/bats test/test_case.bats
 ✗ test with asterisk
   (in test file test/test_case.bats, line 14)
     `[ "$output" = "foo" ]' failed
 ✓ test without asterisk

2 tests, 1 failure
@tommarshall tommarshall linked a pull request Mar 24, 2017 that will close this issue
@chris-redekop
Copy link

I encountered the same issue mocking aws with codebuild batch-get-builds --ids 3 --query builds[0].environment.environmentVariables, i.e. with arguments that contain [0] instead of [*]. Your PR #8 fixed the issue for me, @tommarshall . Thanks.

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

Successfully merging a pull request may close this issue.

2 participants