-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgovernance.bats
67 lines (59 loc) · 1.5 KB
/
governance.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bats
load "helpers"
setup_file() {
start_server
login_superadmin
}
teardown_file() {
stop_server
}
trigger_withdraw_approval_process() {
variables=$(
jq -n \
--arg deposit_account_id "$1" \
'{
input: {
depositAccountId: $deposit_account_id,
amount: 1000000,
}
}'
)
exec_admin_graphql 'record-deposit' "$variables"
variables=$(
jq -n \
--arg deposit_account_id "$1" \
--arg date "$(date +%s%N)" \
'{
input: {
depositAccountId: $deposit_account_id,
amount: 150000,
reference: ("withdrawal-ref-" + $date)
}
}'
)
exec_admin_graphql 'initiate-withdrawal' "$variables"
process_id=$(graphql_output .data.withdrawalInitiate.withdrawal.approvalProcessId)
[[ "$process_id" != "null" ]] || exit 1
echo $process_id
}
@test "governance: auto-approve" {
customer_id=$(create_customer)
cache_value "customer_id" $customer_id
variables=$(
jq -n \
--arg id "$customer_id" \
'{ id: $id }'
)
exec_admin_graphql 'customer' "$variables"
deposit_account_id=$(graphql_output .data.customer.depositAccount.depositAccountId)
cache_value "deposit_account_id" $deposit_account_id
process_id=$(trigger_withdraw_approval_process $deposit_account_id)
variables=$(
jq -n \
--arg id "$process_id" \
'{ id: $id }'
)
exec_admin_graphql 'find-approval-process' "$variables"
status=$(graphql_output .data.approvalProcess.status)
[[ "$status" == "APPROVED" ]] || exit 1
}