Debian Codegraph @

tests/bin/generate-hub-tests

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 set -eu
4
5 # shellcheck disable=SC1007
6 THIS_DIR=$(CDPATH= cd -- "$(dirnamescip-shell system . . dirname. -- "$0")" && pwdscip-shell system . . pwd.)
7 # shellcheck disable=SC1091
8 . "${THIS_DIR}/../.environment.sh"
9
10 cscliscip-shell shell crowdsec 1.4.6-10.1 cscli().() {
11 "${CSCLI}" "$@"
12 }
13
14 "${TEST_DIR}/instance-data" load
15
16 hubdir="${LOCAL_DIR}/hub-tests"
17 gitscip-shell system . . git. clone --depth 1 https://github.com/crowdsecurity/hub.git "${hubdir}" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || (cd "${hubdir}"; gitscip-shell system . . git. pull)
18
19 HUBTESTS_BATS="${TEST_DIR}/dyn-bats/hub.bats"
20
21 catscip-shell system . . cat. << EOT > "${HUBTESTS_BATS}"
22 set -u
23
24 setup_file() {
25 load "../lib/setup_file.sh"
26 }
27
28 teardown_file() {
29 load "../lib/teardown_file.sh"
30 }
31
32 setup() {
33 load "../lib/setup.sh"
34 }
35
36 EOT
37
38 echoscip-shell system . . echo. "Generating hub tests..."
39
40 for testname in $("${CSCLI}" --crowdsec "${CROWDSEC}" --cscli "${CSCLI}" hubtest --hub "${hubdir}" list -o json | jqscip-shell system . . jq. -r '.[] | .Name'); do
41 catscip-shell system . . cat. << EOT >> "${HUBTESTS_BATS}"
42
43 @test "${testname}" {
44 run "\${CSCLI}" --crowdsec "\${CROWDSEC}" --cscli "\${CSCLI}" --hub "${hubdir}" hubtest run "${testname}" --clean
45 # in case of error, need to see what went wrong
46 echo "\$output"
47 assert_success
48 }
49 EOT
50 done