-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_script.sh
More file actions
executable file
·90 lines (76 loc) · 2.32 KB
/
Copy pathtest_script.sh
File metadata and controls
executable file
·90 lines (76 loc) · 2.32 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
super_duper_function_to_run_the_test() {
actual_output="$1"
expected_output="$2"
if [ "$output" = "$expected_output" ]; then
echo "Test passed"
else
echo "Test failed"
echo "Expected output:"
echo "$expected_output"
echo "Actual output:"
echo "$actual_output"
fi
}
docker build -q -t calculator .
# Test for "CNSHA \n NLRTM \n cheapest-direct \n"
output=$(printf "CNSHA \n NLRTM \n cheapest-direct \n" | docker run -i --rm calculator)
expected_output='[
{
"origin_port": "CNSHA",
"destination_port": "NLRTM",
"departure_date": "2022-01-30",
"arrival_date": "2022-03-05",
"sailing_code": "MNOP",
"rate": "456.78",
"rate_currency": "USD"
}
]'
super_duper_function_to_run_the_test "$output" "$expected_output"
# Test for "CNSHA \n NLRTM \n fastest \n"
output=$(printf "CNSHA \n NLRTM \n fastest \n" | docker run -i --rm calculator)
expected_output='[
{
"origin_port": "CNSHA",
"destination_port": "NLRTM",
"departure_date": "2022-01-29",
"arrival_date": "2022-02-15",
"sailing_code": "QRST",
"rate": "761.96",
"rate_currency": "EUR"
}
]'
super_duper_function_to_run_the_test "$output" "$expected_output"
# Test for "CNSHA \n NLRTM \n cheapest \n"
output=$(printf "CNSHA \n NLRTM \n cheapest \n" | docker run -i --rm calculator)
expected_output='[
{
"origin_port": "CNSHA",
"destination_port": "ESBCN",
"departure_date": "2022-01-29",
"arrival_date": "2022-02-12",
"sailing_code": "ERXQ",
"rate": "261.96",
"rate_currency": "EUR"
},
{
"origin_port": "ESBCN",
"destination_port": "NLRTM",
"departure_date": "2022-02-16",
"arrival_date": "2022-02-20",
"sailing_code": "ETRG",
"rate": "69.96",
"rate_currency": "USD"
}
]'
super_duper_function_to_run_the_test "$output" "$expected_output"
# Test for "qwe \n rty \n coolest \n"
output=$(printf "qwe \n rty \n coolest \n" | docker run -i --rm calculator)
expected_output="Invalid input"
super_duper_function_to_run_the_test "$output" "$expected_output"
# Test for "qwe \n rty \n cheapest \n"
output=$(printf "qwe \n rty \n cheapest \n" | docker run -i --rm calculator)
expected_output="No sailings found between qwe and rty"
super_duper_function_to_run_the_test "$output" "$expected_output"
# Run rspec in Docker
docker run --rm calculator rspec