prole/tests/shellspec/.vendor/shellspec-0.28.1/examples/spec/04.evaluation_spec.sh
chrisfu 909e92109e Refactor shell layout; add shellspec + authority
- Introduce lib/shell helpers and keep etc/* scripts thin via compatibility shims

- Move Kerberos validation to scripts/validation/check_kerberos.sh and update callers

- Add deterministic shellspec unit tests under tests/shellspec/ and wire Maven to run them

- Add minimal Spring Boot authority module with startup + /health endpoint and Maven wiring

- Document the new layout in docs/layout.md

Co-authored-by: Junie <junie@jetbrains.com>
2026-03-13 09:19:56 -07:00

76 lines
1.9 KiB
Bash

#shellcheck shell=sh disable=SC2016
Describe 'evaluation example'
Describe 'call evaluation'
It 'calls function'
foo() { echo "foo"; }
When call foo # this is evaluation
The output should eq "foo"
End
It 'calls external command also'
When call expr 1 + 2
The output should eq 3
End
It 'calls the defined function instead of external command that same name'
expr() { echo "be called"; }
When call expr 1 + 2
The output should eq "be called"
End
It 'must be one call each example'
When call echo 1
When call echo 2 # can not be called more than once.
The output should eq 1
End
It 'not calling is allowed'
The value 123 should eq 123
End
It 'can not be called after expectation'
The value 123 should eq 123
When call echo 1 # can not be called after expectation.
End
It 'calls external command'
expr() { echo "not called"; }
When run command expr 1 + 2
The output should eq 3
End
End
Describe 'run evaluation'
It 'can trap exit'
abort() { exit 1; }
When run abort # if use "call evaluation", shellspec is terminate
The status should be failure
End
It 'can not modify variable because it run with in subshell'
set_value() { SHELLSPEC_VERSION=$1; }
When run set_value 'no-version'
The value "$SHELLSPEC_VERSION" should not eq 'no-version'
End
It 'calls BeforeRun/AfterRun hook'
before_run() {
# You can temporary redefine function here
# redefined function is restored after run evaluation
# because run evaluation runs with in subshell
echo before
}
after_run() {
echo after
}
BeforeRun before_run
AfterRun after_run
When run echo 123
The line 1 of output should eq 'before'
The line 2 of output should eq 123
The line 3 of output should eq 'after'
End
End
End