Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

bats script not working #69

Closed
mohit1007 opened this issue Aug 15, 2014 · 2 comments
Closed

bats script not working #69

mohit1007 opened this issue Aug 15, 2014 · 2 comments

Comments

@mohit1007
Copy link

@test "Pinging server" {
run curl -I http://localhost:8088/tracks?key=9 | head -n 1| cut -d $' ' -f2
[ "$status" -eq 200 ]
}

Essentially, this means, grab the status code?
But i get the following error:
`[ "$status" -eq 200 ]' failed with status 2
/var/folders/7w/h7x7t8wn66v8bts2_cr1d3sm0000gp/T/bats.87996.src: line 10: [: : integer expression expected

@mislav
Copy link
Collaborator

mislav commented Aug 15, 2014

You're using run wrong. You can't pipe commands to it, I'm afraid, due to the way it's implemented internally. You should just use it to invoke one executable from PATH with arguments. Bats will save standard output/error to $output variable.

@thomd
Copy link

thomd commented Aug 16, 2014

isolate the test inside a command group like this:

@test "Pinging server" {
  curl -I http://localhost:8088/tracks?key=9 | head -n 1 | {
    run cut -d $' ' -f2
    [ $output -eq 200 ]
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants