1
1
'\" t
2
2
.\" Title: bash_unit
3
3
.\" Author: [see the "AUTHOR(S)" section]
4
- .\" Generator: Asciidoctor 2.0.16
5
- .\" Date: 2022-01-05
4
+ .\" Generator: Asciidoctor 2.0.17
5
+ .\" Date: 2022-06-17
6
6
.\" Manual: \ \&
7
7
.\" Source: \ \&
8
8
.\" Language: English
9
9
.\"
10
- .TH "BASH_UNIT" "1" "2022-01-05 " "\ \& " "\ \& "
10
+ .TH "BASH_UNIT" "1" "2022-06-17 " "\ \& " "\ \& "
11
11
.ie \n( .g .ds Aq \(aq
12
12
.el .ds Aq '
13
13
.ss \n[ .ss ] 0
@@ -110,6 +110,7 @@ Running tests in tests/test_core.sh
110
110
Running test_fake_echo_stdin_when_no_params ... SUCCESS
111
111
Running test_fake_exports_faked_in_subshells ... SUCCESS
112
112
Running test_fake_transmits_params_to_fake_code ... SUCCESS
113
+ Running test_fake_transmits_params_to_fake_code_as_array ... SUCCESS
113
114
Running test_should_pretty_format_even_when_LANG_is_unset ... SUCCESS
114
115
Overall result: SUCCESS
115
116
.fam
@@ -199,6 +200,7 @@ ok \- test_fake_can_fake_inline
199
200
ok \- test_fake_echo_stdin_when_no_params
200
201
ok \- test_fake_exports_faked_in_subshells
201
202
ok \- test_fake_transmits_params_to_fake_code
203
+ ok \- test_fake_transmits_params_to_fake_code_as_array
202
204
ok \- test_should_pretty_format_even_when_LANG_is_unset
203
205
.fam
204
206
.fi
@@ -607,12 +609,37 @@ doc:2:test_obvious_matching_with_assert_not_matches()
607
609
.if n .RS 4
608
610
.nf
609
611
.fam C
610
- assert_no_diff <expected\- file > <actual\- file > [message]
612
+ assert_no_diff <expected> <actual> [message]
611
613
.fam
612
614
.fi
613
615
.if n .RE
614
616
.sp
615
- Asserts that the content of \f(CR expected \- file \fP matches the content of \f(CR actual \- file \fP .
617
+ Asserts that the content of the file \fI actual \fP does not have any differences to the one \fI expected \fP .
618
+ .sp
619
+ .if n .RS 4
620
+ .nf
621
+ .fam C
622
+ test_obvious_notmatching_with_assert_no_diff(){
623
+ assert_no_diff bash_unit README.adoc "content of \*( Aq README.adoc\*( Aq should be the same as \*( Aq bash_unit\*( Aq "
624
+ }
625
+ test_obvious_matching_with_assert_assert_no_diff(){
626
+ assert_no_diff bash_unit bash_unit
627
+ }
628
+ .fam
629
+ .fi
630
+ .if n .RE
631
+ .sp
632
+ .if n .RS 4
633
+ .nf
634
+ .fam C
635
+ Running test_obvious_matching_with_assert_assert_no_diff ... SUCCESS
636
+ Running test_obvious_notmatching_with_assert_no_diff ... FAILURE
637
+ content of \*( Aq README.adoc\*( Aq should be the same as \*( Aq bash_unit\*( Aq
638
+ expected \*( Aq README.adoc\*( Aq to be identical to \*( Aq bash_unit\*( Aq but was different
639
+ doc:2:test_obvious_notmatching_with_assert_no_diff()
640
+ .fam
641
+ .fi
642
+ .if n .RE
616
643
.SH "\fB FAKE \fP FUNCTION"
617
644
.sp
618
645
.if n .RS 4
@@ -668,7 +695,7 @@ hello world
668
695
.if n .RE
669
696
.SS "Using stdin"
670
697
.sp
671
- Here is an exemple , parameterizing fake with its \fI stdin \fP to test that code fails when some process does not run and succeeds otherwise:
698
+ Here is an example , parameterizing fake with its \fI stdin \fP to test that code fails when some process does not run and succeeds otherwise:
672
699
.sp
673
700
.if n .RS 4
674
701
.nf
@@ -819,7 +846,7 @@ It can also help in asserting the values of these parameters ... but this may be
819
846
.sp
820
847
For instance, in our previous code that checks apache is running, we have an issue since our code does not use \fI ps \fP with the appropriate parameters. So we will try to check that parameters given to ps are \fI ax \fP .
821
848
.sp
822
- To do that, the first naive approch would be:
849
+ To do that, the first naive approach would be:
823
850
.sp
824
851
.if n .RS 4
825
852
.nf
@@ -836,7 +863,7 @@ test_code_gives_ps_appropriate_parameters() {
836
863
24162 pts/7 00:00:00 ps
837
864
8387 ? 0:00 /usr/sbin/apache2 \- k start
838
865
EOF
839
- assert_equals ax "$FAKE_PARAMS"
866
+ assert_equals ax "${ FAKE_PARAMS[@]} "
840
867
}
841
868
export \- f _ps
842
869
fake ps _ps
@@ -882,7 +909,7 @@ code() {
882
909
883
910
test_code_gives_ps_appropriate_parameters() {
884
911
_ps() {
885
- assert_equals ax "$FAKE_PARAMS"
912
+ assert_equals ax "${ FAKE_PARAMS[@]} "
886
913
}
887
914
export \- f _ps
888
915
fake ps _ps
@@ -920,7 +947,7 @@ code() {
920
947
921
948
test_code_gives_ps_appropriate_parameters() {
922
949
_ps() {
923
- echo $FAKE_PARAMS > /tmp/fake_params
950
+ echo ${ FAKE_PARAMS[@]} > /tmp/fake_params
924
951
}
925
952
export \- f _ps
926
953
fake ps _ps
@@ -962,7 +989,7 @@ code() {
962
989
}
963
990
964
991
test_code_gives_ps_appropriate_parameters() {
965
- fake ps \*( Aq echo $FAKE_PARAMS >/tmp/fake_params\*( Aq
992
+ fake ps \*( Aq echo ${ FAKE_PARAMS[@]} >/tmp/fake_params\*( Aq
966
993
967
994
code || true
968
995
@@ -999,7 +1026,7 @@ test_get_data_from_fake() {
999
1026
#Fasten you seat belt ...
1000
1027
coproc cat
1001
1028
exec {test_channel}>&${COPROC[1]}
1002
- fake ps \*( Aq echo $FAKE_PARAMS >&$test_channel\*( Aq
1029
+ fake ps \*( Aq echo ${ FAKE_PARAMS[@]} >&$test_channel\*( Aq
1003
1030
1004
1031
code || true
1005
1032
0 commit comments