goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.55k stars 473 forks source link

How command option works? #584

Closed BeamerIsHere closed 4 years ago

BeamerIsHere commented 4 years ago

Hi All,

I'm bit confused about command option, Is it just to check whether a command is there or not? or can I run some command during the testing using goss.yaml?

My requirement is to test a command during the dgoss run process. Example :- I want to run a script inside the container using dgoss ( goss add command ./bashscript) while testing the container using dgoss run command. Is that possible.?

aelsabbahy commented 4 years ago

The command option runs the script and allows you to validate exit-status or output of the command: https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#command

Example:

command:
  echo hello world:
    exit-status: 0
    stdout:
    - hello world
    stderr: []
    timeout: 10000
BeamerIsHere commented 4 years ago

Thanks for the reply @aelsabbahy, I've copied my bash script into the image and ran that script with command option through dgoss edit and it worked!

eg:- goss add command "bash "

aelsabbahy commented 4 years ago

Awesome, glad it worked!