-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcli-test.sh
executable file
·48 lines (34 loc) · 1.75 KB
/
cli-test.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
47
48
#!/bin/bash
set -e
set -x
CLI_CMD=zlog
LMDB_DIR=$(mktemp -d)
INPUT_FILE=$(mktemp)
OUTPUT_FILE=$(mktemp)
EXPECTED_FILE=$(mktemp)
trap "rm -rf ${LMDB_DIR} ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECTED_FILE}" exit
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log create testlog
! ${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log create testlog
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log append testlog 'just a lil test'
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log append testlog 'and another'
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log append testlog 'one more and were done'
echo '616e6420616e6f74686572' >> ${EXPECTED_FILE}
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log read testlog 1 >> ${OUTPUT_FILE}
diff ${EXPECTED_FILE} ${OUTPUT_FILE}
> ${EXPECTED_FILE}
> ${OUTPUT_FILE}
echo 'arthur willey!' >> ${INPUT_FILE}
echo 'nautili hunter' >> ${INPUT_FILE}
echo 'abcdefghijlmno' >> ${INPUT_FILE}
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log append testlog -i ${INPUT_FILE}
echo '0: 6a7573742061206c696c2074657374' >> ${EXPECTED_FILE}
echo '1: 616e6420616e6f74686572' >> ${EXPECTED_FILE}
echo '2: 6f6e65206d6f726520616e64207765726520646f6e65' >> ${EXPECTED_FILE}
echo '3: 6172746875722077696c6c6579210a6e617574696c692068756e7465720a6162636465666768696a6c6d6e6f0a' >> ${EXPECTED_FILE}
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log dump testlog >> ${OUTPUT_FILE}
diff ${EXPECTED_FILE} ${OUTPUT_FILE}
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log fill testlog 30
! ${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log fill testlog 1
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log trim testlog 2
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log views testlog
${CLI_CMD} --backend lmdb --db-path ${LMDB_DIR} log get testlog