@@ -5,6 +5,73 @@ export CLOE_ROOT="${BATS_TEST_DIRNAME}/../../.."
5
5
load " ${CLOE_ROOT} /tests/setup_bats.bash"
6
6
load " ${CLOE_ROOT} /tests/setup_testname.bash"
7
7
8
+ # Usage: FILENAME=$(mktemp_gndtruth_out SUFFIX)
9
+ #
10
+ # Prints a new temporary filename with the given suffix.
11
+ # This allows different tests be run in parallel.
12
+ mktemp_gndtruth_out () {
13
+ local suffix=${1}
14
+ mktemp -u --suffix=.${suffix} /tmp/cloe-gndtruth-XXXXX
15
+ }
16
+
17
+ # Usage: fn_test_gndtruth SUFFIX DECOMPRESS
18
+ #
19
+ # Parameters:
20
+ # SUFFIX One of "json", "json.gz", "json.bz2", "msgpack", "msgpack.gz", "msgpack.bz2"
21
+ # DECOMPRESS One of "cat", "gunzip", "bunzip2"
22
+ fn_test_gndtruth () {
23
+ local suffix=" $1 "
24
+ local decompress=" $2 "
25
+
26
+ # This neat little trick will give us "json" or "msgpack"
27
+ local base_suffix=" ${suffix/ .*/ } "
28
+ local CLOE_GNDTRUTH_REF=" test_gndtruth_smoketest_output.${base_suffix} "
29
+
30
+ export CLOE_GNDTRUTH_OTYPE=" $suffix "
31
+ export CLOE_GNDTRUTH_ONAME=" $( mktemp_gndtruth_out $suffix ) "
32
+
33
+ # Clean any pre-existing file.
34
+ if [ -f " $CLOE_GNDTRUTH_ONAME " ]; then
35
+ rm " $CLOE_GNDTRUTH_ONAME "
36
+ fi
37
+
38
+ cloe-engine run test_gndtruth_smoketest.json
39
+ assert_exit_success $?
40
+
41
+ # Expect configured output file to exist.
42
+ test -f " $CLOE_GNDTRUTH_ONAME "
43
+
44
+ # Expect reference file to equal the "decompressed" output file
45
+ diff " $CLOE_GNDTRUTH_REF " <( $decompress - < " $CLOE_GNDTRUTH_ONAME " )
46
+
47
+ # Remove temporary file.
48
+ rm " $CLOE_GNDTRUTH_ONAME "
49
+ }
50
+
51
+ @test " $( testname ' Expect json' ' test_gndtruth_smoketest.json' ' d5f58690-e7bc-4170-ab7e-9b785a5866c3' ) " {
52
+ fn_test_gndtruth " json" " cat"
53
+ }
54
+
55
+ @test " $( testname ' Expect json.gz' ' test_gndtruth_smoketest.json' ' b3a11bb5-6fd1-401e-b9fb-db76b4c338e5' ) " {
56
+ fn_test_gndtruth " json.gz" " gunzip"
57
+ }
58
+
59
+ @test " $( testname ' Expect json.bz2' ' test_gndtruth_smoketest.json' ' 69eeb436-4b5e-4a31-9097-01f03cb0f71d' ) " {
60
+ fn_test_gndtruth " json.bz2" " bunzip2"
61
+ }
62
+
63
+ @test " $( testname ' Expect msgpack' ' test_gndtruth_smoketest.json' ' 40757b44-3aa0-4a46-8597-ebf2b8acfbab' ) " {
64
+ fn_test_gndtruth " msgpack" " cat"
65
+ }
66
+
67
+ @test " $( testname ' Expect msgpack.gz' ' test_gndtruth_smoketest.json' ' bf77683f-7c1a-4d70-b713-e26f440e71f7' ) " {
68
+ fn_test_gndtruth " msgpack.gz" " gunzip"
69
+ }
70
+
71
+ @test " $( testname ' Expect msgpack.bz2' ' test_gndtruth_smoketest.json' ' c50350d5-9b63-43bb-9e00-d31646e50b0a' ) " {
72
+ fn_test_gndtruth " msgpack.bz2" " bunzip2"
73
+ }
74
+
8
75
@test " $( testname ' Expect run failure' ' test_gndtruth_invalid_file.json' ' 29e8ff3b-86f3-4320-ba69-05600df1f836' ) " {
9
76
cloe-engine check test_gndtruth_invalid_file.json
10
77
run cloe-engine run test_gndtruth_invalid_file.json
0 commit comments