-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathterms_template.bats
98 lines (80 loc) · 2.25 KB
/
terms_template.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
load "helpers"
setup_file() {
start_server
login_superadmin
}
teardown_file() {
stop_server
}
@test "terms-template: can create" {
template_name="Test Template $(date +%s)"
variables=$(
jq -n \
--arg name "$template_name" \
'{
input: {
name: $name,
annualRate: 5.5,
accrualInterval: "END_OF_MONTH",
incurrenceInterval: "END_OF_DAY",
oneTimeFeeRate: "5",
duration: {
period: "MONTHS",
units: 12
},
liquidationCvl: 80,
marginCallCvl: 90,
initialCvl: 100
}
}'
)
exec_admin_graphql 'terms-template-create' "$variables"
terms_template_id=$(graphql_output '.data.termsTemplateCreate.termsTemplate.termsId')
[[ "$terms_template_id" != "null" ]] || exit 1
cache_value 'terms_template_id' "$terms_template_id"
}
@test "terms-template: can update" {
terms_template_id=$(read_value 'terms_template_id')
variables=$(
jq -n \
--arg id "$terms_template_id" \
'{
input: {
id: $id,
annualRate: 6.5,
accrualInterval: "END_OF_MONTH",
incurrenceInterval: "END_OF_DAY",
oneTimeFeeRate: "5",
duration: {
period: "MONTHS",
units: 24
},
liquidationCvl: 75,
marginCallCvl: 85,
initialCvl: 95
}
}'
)
exec_admin_graphql 'terms-template-update' "$variables"
updated_id=$(graphql_output '.data.termsTemplateUpdate.termsTemplate.termsId')
[[ "$updated_id" == "$terms_template_id" ]] || exit 1
annual_rate=$(graphql_output '.data.termsTemplateUpdate.termsTemplate.values.annualRate')
[[ "$annual_rate" == "6.5" ]] || exit 1
}
@test "terms-template: can retrieve" {
terms_template_id=$(read_value 'terms_template_id')
variables=$(
jq -n \
--arg id "$terms_template_id" \
'{
id: $id
}'
)
exec_admin_graphql 'terms-template-get' "$variables"
retrieved_id=$(graphql_output '.data.termsTemplate.termsId')
[[ "$retrieved_id" == "$terms_template_id" ]] || exit 1
annual_rate=$(graphql_output '.data.termsTemplate.values.annualRate')
[[ "$annual_rate" == "6.5" ]] || exit 1
duration_units=$(graphql_output '.data.termsTemplate.values.duration.units')
[[ "$duration_units" == "24" ]] || exit 1
}