Giter VIP home page Giter VIP logo

bash_shell_mock's People

Contributors

captainquirk avatar ckstettler avatar gforsyth avatar jdorfman avatar mend-bolt-for-github[bot] avatar meustrus avatar nitinsurana avatar ospo-capitalone avatar particleflux avatar potherca avatar sheosinha avatar tmbjmu avatar tyleroconnell avatar vsimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash_shell_mock's Issues

Contributors agreement

@nitinsurana @jdorfman @particleflux @meustrus it seems I had the cart before the horse regarding CapitalOne's opensource contributor policy. All contributors are suppose to complete a CLM prior to me accepting the PR. Obviously that ship has sailed.

I have a PR to add this information within the repo for future contributors. The link is here https://developer.capitalone.com/open-source/

Would you visit the site and read the CLM and if you can agree to it? If so then please submit one. Much of the language is with regard to patent rights which I don't for see being an issue here. I have valued your inputs so far and hope to see your continued use and support. If you can't agree to it I certainly understand.

Automate test execution during PRs

Though there's fairly extensive testing of bashshellmock.sh, there is currently nothing running these in an automated fashion on our PRs. Given it may be more trouble than it's worth to integrate our enterprise Jenkins instances to interact with public GitHub, this issue entails evaluating which (hosted) continuous integration platform to use:

  • Research other @capitalone repositories to see what continuous integration platform they are using
  • Finalize which continuous integration platform to use, with approval from the open source office
  • Created an automated script to execute and check the results of the sample-bats and test

Documentation bug.

The formatting of the readme is not right. The formatting of the table in the shellmock_expect has some sort of syntax issue.

Mishandling of " contained in mock matches.

When adding some new example test cases:

@test "sample.sh-success-partial-mock" {

    shellmock_expect grep --status 0 --output "Mocked output for Partial Match" --type partial --match '"sample line"'

    run ./sample.sh

    shellmock_dump

    [ "$status" = "0" ]

    # Validate using lines array.
    [ "${lines[0]}" = "Mocked output for Partial Match" ]

    # Optionally since this is a single line you can use $output
    [ "$output" = "Mocked output for Partial Match" ]

}

This test failed to match even though sample.sh passes this double quoted string as one argument.

Regex matching of arguments being passed

node -e "require('./helper').validate()"

Above is how my function call looks. I can't seem to find a corresponding shellmock_expect --match argument. I've tried various combinations like :

shellmock_expect node --status 1 --match '-e "require('./helper').validate()"'
shellmock_expect node --status 1 --match '-e "require(\'./helper\').validate()"'
shellmock_expect node --status 1 --match '-e "require(\"./helper\").validate()"'

throws status 99

mock custom functions

If I have the following functions file:
functions_file.sh:

  docker_user="$1"
  docker_password="$2"
  docker_registry="$3"
  docker login -p ${docker_password} -u ${docker_user} ${registry}
}

main_function(){
    helper_function user1 password1 nonexsistent.domain.com
}

And the bats file:

load 'libs/bats-assert/load'

setup() {
  . shellmock
  source functions_file.sh
  skipIfNot "$BATS_TEST_DESCRIPTION"
  shellmock_clean
}

teardown() {
  if [[ -z "$TEST_FUNCTION" ]]; then
    shellmock_clean
  fi
}

stub_functions() {
  shellmock_expect helper_function --match "user1 password1 registry.domain.com"
}

@test "main" {
  stub_functions
  run main_function
  assert_equal "$status" 0
}

I don't seem to be able to mock the function help_function

--match string containing double quotes cannot find the given argument

The easiest example of this is in the sample-bats directory, if you look at the "sample.sh failure" test, modifying the status of the grep command from 1 to 0 does not affect the outcome of the test. This is because shellmock cannot find the grep command to begin with. Easy way to see this is to reverse the if conditional on teardown to see the shellmock error log.

The current workaround that I've been using is to utilize the '--type partial' flag and not look for double quotes in the --match argument.

Verify that command receives specific data through stdin

Hi there !

I'm programmatically doing something like echo 0 */2 * * * my_user my_script | crontab - to add an entry in the current user's crontab.

Can I check that the crontab really got 0 */2 * * * my_user my_script from STDIN with bash_shell_mock ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.