From c3840a0e68ecc5249c0c6c2e2e5efadd7bf18dc8 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Mon, 24 Oct 2016 12:57:53 +0300 Subject: [PATCH] HG-63: Fill proper account ids in the base fixture (#6) --- ...commit.json => base-fixture.commit.json.tpl} | 17 +++++++++++++++-- scripts/dominant/commit-base-fixture.sh | 9 ++++++++- scripts/dominant/create-account.sh | 11 +++++++++++ scripts/lib/template.sh | 5 +++++ 4 files changed, 39 insertions(+), 3 deletions(-) rename scripts/dominant/{base-fixture.commit.json => base-fixture.commit.json.tpl} (89%) create mode 100755 scripts/dominant/create-account.sh create mode 100755 scripts/lib/template.sh diff --git a/scripts/dominant/base-fixture.commit.json b/scripts/dominant/base-fixture.commit.json.tpl similarity index 89% rename from scripts/dominant/base-fixture.commit.json rename to scripts/dominant/base-fixture.commit.json.tpl index 56a3bca..22b57e6 100644 --- a/scripts/dominant/base-fixture.commit.json +++ b/scripts/dominant/base-fixture.commit.json.tpl @@ -4,7 +4,16 @@ "data": { "party_prototype": {"id": 42}, "providers": {"value": [{"id": 1}]}, - "system_accounts": {"predicates": []} + "system_accounts": {"value": [{"id": 1}]} + } + }}}}, + {"insert": {"object": {"system_account_set": { + "ref": {"id": 1}, + "data": { + "name": "Primary", + "description": "Primary", + "currency": {"symbolic_code": "RUB"}, + "compensation": $(${CURDIR}/create-account.sh RUB $*) } }}}}, {"insert": {"object": {"party_prototype": { @@ -127,7 +136,11 @@ "volume": {"share": {"parts": {"p": 18, "q": 1000}, "of": "payment_amount"}} } ], - "accounts": {"currency": {"symbolic_code": "RUB"}, "receipt": 10, "compensation": 11}, + "accounts": { + "currency": {"symbolic_code": "RUB"}, + "receipt": $(${CURDIR}/create-account.sh RUB $*), + "compensation": $(${CURDIR}/create-account.sh RUB $*) + }, "options": {"override": "Brominal 1"} } }}}}, diff --git a/scripts/dominant/commit-base-fixture.sh b/scripts/dominant/commit-base-fixture.sh index 0475e91..8f4ee55 100755 --- a/scripts/dominant/commit-base-fixture.sh +++ b/scripts/dominant/commit-base-fixture.sh @@ -1,6 +1,13 @@ #!/bin/sh +set -e + +export CURDIR="$(dirname ${0})" +export LIBDIR="${CURDIR}/../lib" + +FIXTURE="$(${LIBDIR}/template.sh ${CURDIR}/base-fixture.commit.json.tpl $*)" + woorl $* \ -s damsel/proto/domain_config.thrift \ http://dominant:8022/v1/domain/repository \ - Repository Commit 0 "$(cat $(dirname $0)/base-fixture.commit.json)" + Repository Commit 0 "${FIXTURE}" diff --git a/scripts/dominant/create-account.sh b/scripts/dominant/create-account.sh new file mode 100755 index 0000000..9f16f25 --- /dev/null +++ b/scripts/dominant/create-account.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +CURRENCY=${1} +shift 1 + +[ -z "${CURRENCY}" ] && { echo "No currency code specified"; exit -1; } + +woorl $* \ + -s damsel/proto/accounter.thrift \ + http://shumway:8022/accounter \ + Accounter CreateAccount "{\"currency_sym_code\":\"${CURRENCY}\"}" diff --git a/scripts/lib/template.sh b/scripts/lib/template.sh new file mode 100755 index 0000000..1c7b3b5 --- /dev/null +++ b/scripts/lib/template.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +eval "shift 1 && cat <