From 908ce9ba56fecd038917703d847308476b1df62a Mon Sep 17 00:00:00 2001 From: Kevin <110382240+Kvindee@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:29:34 +0100 Subject: [PATCH] :white_check_mark: improve samples code testing (#136) (#146) --- .github/workflows/test-sample-codes.yml | 4 ++-- .../{bank_check_1.txt => bank_check_v1.txt} | 0 docs/code_samples/base.csx | 2 +- .../{carte_vitale_1.txt => carte_vitale_v1.txt} | 0 docs/code_samples/{cropper_1.txt => cropper_v1.txt} | 0 docs/code_samples/{custom_1.txt => custom_v1.txt} | 0 ...xpense_receipts_4.txt => expense_receipts_v4.txt} | 0 ...cial_document_1.txt => financial_document_v1.txt} | 0 .../{idcard_fr_1.txt => idcard_fr_v1.txt} | 0 .../code_samples/{invoices_4.txt => invoices_v4.txt} | 0 .../code_samples/{passport_1.txt => passport_v1.txt} | 0 ...roof_of_address_1.txt => proof_of_address_v1.txt} | 0 ...g_containers_1.txt => shipping_containers_v1.txt} | 0 test_sample_code.sh | 12 +++++++----- 14 files changed, 10 insertions(+), 8 deletions(-) rename docs/code_samples/{bank_check_1.txt => bank_check_v1.txt} (100%) rename docs/code_samples/{carte_vitale_1.txt => carte_vitale_v1.txt} (100%) rename docs/code_samples/{cropper_1.txt => cropper_v1.txt} (100%) rename docs/code_samples/{custom_1.txt => custom_v1.txt} (100%) rename docs/code_samples/{expense_receipts_4.txt => expense_receipts_v4.txt} (100%) rename docs/code_samples/{financial_document_1.txt => financial_document_v1.txt} (100%) rename docs/code_samples/{idcard_fr_1.txt => idcard_fr_v1.txt} (100%) rename docs/code_samples/{invoices_4.txt => invoices_v4.txt} (100%) rename docs/code_samples/{passport_1.txt => passport_v1.txt} (100%) rename docs/code_samples/{proof_of_address_1.txt => proof_of_address_v1.txt} (100%) rename docs/code_samples/{shipping_containers_1.txt => shipping_containers_v1.txt} (100%) diff --git a/.github/workflows/test-sample-codes.yml b/.github/workflows/test-sample-codes.yml index b426d331..84df35ed 100644 --- a/.github/workflows/test-sample-codes.yml +++ b/.github/workflows/test-sample-codes.yml @@ -50,11 +50,11 @@ jobs: run: | mkdir "${{ github.workspace }}/localNuget" dotnet nuget add source "${{ github.workspace }}/localNuget" -n "NugetLocal" - dotnet nuget list source - dotnet pack "src/Mindee" --version-suffix "test" -p:TargetFrameworks=${{ matrix.dotnet-version }} --output nuget + dotnet pack "src/Mindee" --version-suffix "for-sample-codes" -p:TargetFrameworks=${{ matrix.dotnet-version }} --output nuget cd nuget dotnet nuget push *.nupkg --source "NugetLocal" dotnet tool install -g dotnet-script + dotnet nuget disable source nuget.org - name: Tests sample code run: | diff --git a/docs/code_samples/bank_check_1.txt b/docs/code_samples/bank_check_v1.txt similarity index 100% rename from docs/code_samples/bank_check_1.txt rename to docs/code_samples/bank_check_v1.txt diff --git a/docs/code_samples/base.csx b/docs/code_samples/base.csx index 8cd5f83f..7a7cd49c 100644 --- a/docs/code_samples/base.csx +++ b/docs/code_samples/base.csx @@ -1,2 +1,2 @@ #!/usr/bin/env dotnet-script -#r "nuget: Mindee, 2.1.0-test" +#r "nuget: Mindee, *-*" diff --git a/docs/code_samples/carte_vitale_1.txt b/docs/code_samples/carte_vitale_v1.txt similarity index 100% rename from docs/code_samples/carte_vitale_1.txt rename to docs/code_samples/carte_vitale_v1.txt diff --git a/docs/code_samples/cropper_1.txt b/docs/code_samples/cropper_v1.txt similarity index 100% rename from docs/code_samples/cropper_1.txt rename to docs/code_samples/cropper_v1.txt diff --git a/docs/code_samples/custom_1.txt b/docs/code_samples/custom_v1.txt similarity index 100% rename from docs/code_samples/custom_1.txt rename to docs/code_samples/custom_v1.txt diff --git a/docs/code_samples/expense_receipts_4.txt b/docs/code_samples/expense_receipts_v4.txt similarity index 100% rename from docs/code_samples/expense_receipts_4.txt rename to docs/code_samples/expense_receipts_v4.txt diff --git a/docs/code_samples/financial_document_1.txt b/docs/code_samples/financial_document_v1.txt similarity index 100% rename from docs/code_samples/financial_document_1.txt rename to docs/code_samples/financial_document_v1.txt diff --git a/docs/code_samples/idcard_fr_1.txt b/docs/code_samples/idcard_fr_v1.txt similarity index 100% rename from docs/code_samples/idcard_fr_1.txt rename to docs/code_samples/idcard_fr_v1.txt diff --git a/docs/code_samples/invoices_4.txt b/docs/code_samples/invoices_v4.txt similarity index 100% rename from docs/code_samples/invoices_4.txt rename to docs/code_samples/invoices_v4.txt diff --git a/docs/code_samples/passport_1.txt b/docs/code_samples/passport_v1.txt similarity index 100% rename from docs/code_samples/passport_1.txt rename to docs/code_samples/passport_v1.txt diff --git a/docs/code_samples/proof_of_address_1.txt b/docs/code_samples/proof_of_address_v1.txt similarity index 100% rename from docs/code_samples/proof_of_address_1.txt rename to docs/code_samples/proof_of_address_v1.txt diff --git a/docs/code_samples/shipping_containers_1.txt b/docs/code_samples/shipping_containers_v1.txt similarity index 100% rename from docs/code_samples/shipping_containers_1.txt rename to docs/code_samples/shipping_containers_v1.txt diff --git a/test_sample_code.sh b/test_sample_code.sh index 2d75af10..57524722 100755 --- a/test_sample_code.sh +++ b/test_sample_code.sh @@ -3,19 +3,21 @@ set -e for f in `find docs/code_samples -name "*.txt"` do echo $f - if echo "$f" | grep -q "custom_1.txt" + if echo "$f" | grep -q "custom_v1.txt" then echo "Not processed." continue - elif echo "$f" | grep -q "default.txt" + fi + + cat docs/code_samples/base.csx $f > _test.csx + + if echo "$f" | grep -q "default.txt" then - cat docs/code_samples/base.csx $f > _test.csx sed -i "s/my-endpoint/bank_account_details/" _test.csx sed -i "s/my-account/mindee/" _test.csx sed -i "s/my-version/1/" _test.csx - else - cat docs/code_samples/base.csx $f > _test.csx fi + sed -i "s/my-api-key/$1/" _test.csx sed -i "s/\/path\/to\/the\/file.ext/tests\/resources\/pdf\/blank_1.pdf/" _test.csx