-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathz-report.bats
68 lines (58 loc) · 1.58 KB
/
z-report.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
#!/usr/bin/env bats
load "helpers"
setup_file() {
start_server
login_superadmin
}
teardown_file() {
stop_server
}
wait_for_complete() {
variables=$(
jq -n \
--arg reportId "$1" \
'{
id: $reportId,
}'
)
exec_admin_graphql 'find-report' "$variables"
echo $(graphql_output)
progress=$(graphql_output .data.report.progress)
[[ "$progress" == "COMPLETE" ]] || return 1
}
@test "report: create" {
skip # while we wait for the report to be fixed / meltano to be integrated
# fake service account used in concourse
if echo "${SA_CREDS_BASE64}" | base64 -d | grep -q "abc_app"; then
skip
fi
exec_admin_graphql 'report-create'
echo $(graphql_output)
report_id=$(graphql_output .data.reportCreate.report.reportId)
[[ "$report_id" != "null" ]] || exit 1
retry 60 2 wait_for_complete "$report_id"
variables=$(
jq -n \
--arg reportId "$report_id" \
'{
input: {
reportId: $reportId
}
}'
)
exec_admin_graphql 'report-download-links' "$variables"
echo $(graphql_output)
links=$(graphql_output .data.reportDownloadLinksGenerate.links)
length=$(echo $links | jq -r 'length')
[[ "$length" -gt "0" ]] || exit 1
for url in $(echo $links | jq -r '.[].url'); do
xml_file_contents=$(curl -fsSL "$url") || exit 1
echo $xml_file_contents | grep "<?xml" || exit 1
done
exec_admin_graphql 'report-list'
report_id_from_list=$(graphql_output \
--arg reportId "$report_id" \
'.data.reports[] | select(.reportId == $reportId) .reportId'
)
[[ "$report_id_from_list" == "$report_id" ]] || exit 1
}