Skip to content

Commit

Permalink
added hook and list integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hattan committed Mar 8, 2021
1 parent c513627 commit 2b0e0fe
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/integration/harness/hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

source scripts/shArg.sh

declare MESSAGE

messageHook() {
local message=$1

echo "message hooked invoked with $message"
echo "Global variable is still available $MESSAGE"
}

# register arguments
shArgs.arg "MESSAGE" -m --message PARAMETER true messageHook

# parse inputs
shArgs.parse $@


12 changes: 12 additions & 0 deletions spec/integration/harness/list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

source scripts/shArg.sh

declare IPS
shArgs.arg "IPS" -i --ips PARAMETER true
shArgs.parse $@

for ip in $IPS
do
echo "ip: $ip"
done
11 changes: 11 additions & 0 deletions spec/integration/hook_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Describe 'shArg'
Include spec/integration/harness/runner.sh

Context "Simple Script Tests"
It 'should parse a csv parameter'
When call run_file "spec/integration/harness/hook.sh" "-m great123"
The output should equal "message hooked invoked with great123 Global variable is still available great123"
End

End
End
16 changes: 16 additions & 0 deletions spec/integration/list_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Describe 'shArg'
Include spec/integration/harness/runner.sh

Context "Simple Script Tests"
It 'should parse a csv parameter'
When call run_file "spec/integration/harness/list.sh" "-i 123,456"
The output should equal "ip: 123 ip: 456"
End

It 'should parse a space delimited parameter'
When call run_file "spec/integration/harness/list.sh" "-i 888 777"
The output should equal "ip: 888 ip: 777"
End

End
End

0 comments on commit 2b0e0fe

Please sign in to comment.