-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_itests.sh
executable file
·46 lines (36 loc) · 1.48 KB
/
run_itests.sh
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
#!/usr/bin/env bash
NC='\033[0m' # Text Reset
YELLOW='\033[0;93m' # Yellow
GREEN='\033[0;92m' # Green
function echoOK() {
echo -e "${NC}${GREEN}${1}${NC}"
}
function echoWarning() {
echo -e "${NC}${YELLOW}${1}${NC}"
}
go build -ldflags "-s -w" -mod vendor -v github.com/oscarpfernandez/immudbcc/cmd/immudb-doc/...
for filename in ./testdata/*.json; do
# Write the JSON document in the database.
echoWarning "*** Storing document: ${filename}"
# Generate random document ID.
docID=$(uuidgen)
./immudb-doc write -doc-id "${docID}" -input-json "${filename}"
# Read the JSON document from the database.
echoWarning "*** Retrieving document: ${filename}"
./immudb-doc read -doc-id "${docID}" -output-json result.json
# Compare the retrieved JSON document with original one.
diff <(jq -S . result.json) <(jq -S . "${filename}") > diff.txt
if [ -s diff.txt ]
then
echo "****************************************************************"
echo "* Failed to Store and Retrieve Document."
echo "* Payload did NOT matched (${filename})"
echo "****************************************************************"
exit 1
else
echoOK "**************************************************************"
echoOK "* Successfully Store and Retrieve Document."
echoOK "* Payload matched for file (${filename})"
echoOK "**************************************************************"
fi
done