Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added sd_return_first_non_zero #24

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ This is the open source implementation of the [LinkeData.Center SDaaS™ product

```
docker compose up -d --build
docker compose exec cli sdaas
bats tests/{unit,functional,system}
exit
docker compose exec cli sdaas bats tests/{unit,functional,system}
docker compose down
```

Expand Down Expand Up @@ -92,10 +90,10 @@ To push a new docker image to docker hub:
```
docker login
# input the docker hub credentials...
VERSION="4.0.0-rc1"
docker build -t linkeddatacenter/sdaas-ce:4.0.0-rc1 .
docker tag linkeddatacenter/sdaas-ce:4.0.0-rc1 linkeddatacenter/sdaas-ce
docker push linkeddatacenter/sdaas-ce:4.0.0-rc1
VERSION="4.0.0-rc2"
docker build -t linkeddatacenter/sdaas-ce:$VERSION .
docker tag linkeddatacenter/sdaas-ce:$VERSION linkeddatacenter/sdaas-ce
docker push linkeddatacenter/sdaas-ce:$VERSION
docker push linkeddatacenter/sdaas-ce:latest
```

Expand Down
7 changes: 7 additions & 0 deletions modules/core
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ sd_abort() {
exit 2
}

sd_return_first_non_zero() {
for element in "$@"; do
if [[ $element -ne 0 ]]; then
return $element
fi
done
}

sd_include() {
local forceFlag=0
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/coreTest.bats
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,21 @@ function teardown {
[ "$status" -eq 0 ]
[[ "${lines[0]}" == "http%3A%2F%2Fw3.org%2F%3Ftest%23name" ]]
}


########## sd_return_first_non_zero

@test "sd_return_first_non_zero" {

#run sd_return_first_non_zero 0
#[ "$status" -eq 0 ]

run sd_return_first_non_zero 0 0 0 0
[ "$status" -eq 0 ]

run sd_return_first_non_zero 0 1 2 3
[ "$status" -eq 1 ]

run sd_return_first_non_zero 0 0 2 3
[ "$status" -eq 2 ]
}