File tree Expand file tree Collapse file tree 3 files changed +74
-6
lines changed
Expand file tree Collapse file tree 3 files changed +74
-6
lines changed Original file line number Diff line number Diff line change @@ -258,9 +258,15 @@ function check_prerequisites() {
258258 done
259259}
260260
261-
262261function print_usage() {
263- _out " Usage: ${SELF} [OPTIONS]"
262+ _header " $( basename " ${SELF} " ) v${__VERSION__} " \
263+ " Usage: ${SELF} [OPTIONS]" \
264+ ' ' \
265+ " dasel: ${DASEL_VER:? } " \
266+ " envsubst: ${ENVSUBST_VER:? } " \
267+ " rsync: ${RSYNC_VER:? } (protocol version ${RSYNC_PROTOCOL_VER:? } )" \
268+ " yq: ${YQ_VER:? } "
269+
264270 _out
265271 _out " Options:"
266272 _out " -c FILE Path to config file for this job"
@@ -269,7 +275,6 @@ function print_usage() {
269275 _out " -n NAME Custom name of the job"
270276 _out " -h Shows this help"
271277 _out
272- _out " Version ${__VERSION__} "
273278}
274279
275280function collect_options() {
@@ -340,6 +345,20 @@ function list_active_jobs() {
340345 fi
341346}
342347
348+ function get_3rd_parties_versions() {
349+ DASEL_VER=" $( _get_version dasel) "
350+ ENVSUBST_VER=" $( _get_version envsubst) "
351+ RSYNC_PROTOCOL_VER=" $( _get_version rsync) "
352+ RSYNC_VER=" $( _get_version rsync 3) "
353+ YQ_VER=" $( _get_version yq) "
354+
355+ export DASEL_VER
356+ export ENVSUBST_VER
357+ export RSYNC_PROTOCOL_VER
358+ export RSYNC_VER
359+ export YQ_VER
360+ }
361+
343362return 0 # FIXME: Remove
344363
345364#
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bats
2+
3+ setup () {
4+ load ' test_helper/common-setup'
5+ _common_setup
6+
7+ unset DASEL_VER
8+ unset ENVSUBST_VER
9+ unset RSYNC_PROTOCOL_VER
10+ unset RSYNC_VER
11+ unset YQ_VER
12+ }
13+
14+ @test " get_3rd_parties_versions" {
15+ # MOCK
16+ dasel () { echo ' lorem ipsum 42' ; }
17+ envsubst () { echo ' lorem ipsum 42' ; }
18+ rsync () { echo ' lorem ipsum foo bar 42' ; }
19+ yq () { echo ' lorem ipsum 42' ; }
20+
21+ # WHEN
22+ get_3rd_parties_versions
23+
24+ # THEN
25+ assert_equal $? 0
26+ assert_equal " ${DASEL_VER:? } " ' 42'
27+ assert_equal " ${ENVSUBST_VER:? } " ' 42'
28+ assert_equal " ${RSYNC_PROTOCOL_VER:? } " ' 42'
29+ assert_equal " ${RSYNC_VER:? } " ' foo'
30+ assert_equal " ${YQ_VER:? } " ' 42'
31+ }
Original file line number Diff line number Diff line change @@ -5,13 +5,31 @@ setup() {
55 _common_setup
66}
77
8+ teardown () {
9+ unset DASEL_VER
10+ unset ENVSUBST_VER
11+ unset RSYNC_PROTOCOL_VER
12+ unset RSYNC_VER
13+ unset YQ_VER
14+ }
15+
816@test " print_usage result" {
17+ # MOCK
18+ export DASEL_VER=' 42'
19+ export ENVSUBST_VER=' 42'
20+ export RSYNC_PROTOCOL_VER=' 42'
21+ export RSYNC_VER=' 42'
22+ export YQ_VER=' 42'
23+
924 # WHEN
10- run print_usage
25+ output= " $( print_usage) "
1126
1227 # THEN
13- assert_success
28+ assert_equal $? 0
1429 assert_output --partial ' Usage:'
1530 assert_output --partial ' Options:'
16- assert_output --partial ' Version'
31+ assert_output --partial ' dasel:'
32+ assert_output --partial ' envsubst:'
33+ assert_output --partial ' rsync:'
34+ assert_output --partial ' yq:'
1735}
You can’t perform that action at this time.
0 commit comments