Skip to content

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

@tommarshall

Description

@tommarshall

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions