Skip to content

Commit

Permalink
added input params to the evaluation function and running tests after…
Browse files Browse the repository at this point in the history
… publish
  • Loading branch information
tptodorov committed Oct 25, 2024
1 parent 6631aca commit e7b0155
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
- uses: actions/checkout@v4
- run: |
sh .github/workflows/publish.sh
- run: |
sh tests/test_mortgage.sh
11 changes: 9 additions & 2 deletions tests/test_mortgage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ DIR_TESTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
source "$DIR_TESTS/assert.sh"

log_header "Test assert : test_assert.sh"
function join_by {
local IFS="$1"
shift
echo "$*"
}

# eval_sheet <sheet_id> <output> [<inputfield=value>]*
eval_sheet() {
local id=$1
local output=$2
reply=$(curl -s -f -H "x-myapiz-key: $SHEET_API_KEY" "https://api.myapiz.com/sheet/$id/eval?output=$output")
local inputs=("${@:3}")
input_query=$(join_by "&" "${inputs[@]}")
reply=$(curl -s -f -H "x-myapiz-key: $SHEET_API_KEY" "https://api.myapiz.com/sheet/$id/eval?output=$output&${input_query}")
key=$(jq '.outputs | keys[] | select(contains("!'"$output"'"))' <<<"$reply")
jq '.outputs['"$key"']' <<<"$reply"
}

test_total_interest() {
log_header "Test :: total_interest"

assert_contain "$(eval_sheet "mortgage.xlsx" I13)" "149442." "total interest is invalid"
assert_contain "$(eval_sheet "mortgage.xlsx" I13 E8=300000)" "149442." "total interest is invalid"

log_header "Test :: total_interest end"
}
Expand Down

0 comments on commit e7b0155

Please sign in to comment.