-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplinterctl_tests.sh
More file actions
executable file
·114 lines (89 loc) · 2.8 KB
/
splinterctl_tests.sh
File metadata and controls
executable file
·114 lines (89 loc) · 2.8 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
# This little scripts tests the splinterctl *interface* to make
# sure we don't break the CLI. It doesn't (and shouldn't) be relied
# on to make sure the underlying library works; that's what the unit
# tests are for. For instance, we don't check to make sure the key
# we get is the key we set *because extensive unit tests already
# did that*, so we're just testing the "workflow" UX.
TEST_STORE="${$}_splinterctl_test"
tests_run=0
tests_passed=0
tests_failed=0
fail()
{
echo "FAIL: ${@}"
tests_failed=$(($tests_failed + 1))
exit 1
}
pass()
{
tests_passed=$(($tests_passed + 1))
echo
}
test()
{
echo "TEST: ${@}"
tests_run=$(($tests_run + 1))
}
report()
{
echo "run: ${tests_run} | passed: ${tests_passed} | failed ${tests_failed}"
[ $tests_run != $tests_passed ] && {
echo "${tests_failed} tests failed, exiting abnormally."
# leave the store just in case the CLI introduced a state issue
exit 1
}
echo "Tests passed. Exiting normally."
# /dev/shm will get very cluttered if you delete the next line:
rm -f /dev/shm/${TEST_STORE}
exit 0
}
test "Initialize store"
./splinterctl init $TEST_STORE || fail "Could not initialize store."
pass
test "Set a key"
./splinterctl --use $TEST_STORE set test_key test_value || fail "Could not set a key."
pass
test "Get a key"
./splinterctl --use $TEST_STORE get test_key || fail "Could not get a key."
pass
test "Get key metadata"
./splinterctl --use $TEST_STORE head test_key || fail "Could not get key metadata."
pass
test "List keys"
./splinterctl --use $TEST_STORE list || fail "Could not list keys"
pass
test "Type name a key"
./splinterctl --use $TEST_STORE type test_key vartext || fail "Could not type test_key as vartext"
pass
test "Get key type"
./splinterctl --use $TEST_STORE type test_key || fail "Could not get type of test_key"
pass
test "Lua script integration"
./splinterctl --use $TEST_STORE lua test.lua || fail "Could not run lua script."
pass
test "Unset a key"
./splinterctl --use $TEST_STORE unset test_key || fail "Could not unset test key"
pass
test "Get global config"
./splinterctl --use $TEST_STORE config || fail "Could not get global config."
pass
test "Set a global config flag"
./splinterctl --use $TEST_STORE config av 1 || fail "Could not set global config flag"
pass
test "Export store metadata"
./splinterctl --use $TEST_STORE export || fail "Could not export JSON"
pass
test "Set a new bump key"
./splinterctl --use $TEST_STORE set bump_key "Bump Value" || fail "Could not set bump key"
pass
test "Bump the bump key"
./splinterctl --use $TEST_STORE bump bump_key || fail "Could not bump the bump key"
pass
test "Append the bump key"
./splinterctl --use $TEST_STORE append bump_key "\nDo the bumpty-bump." || fail "Could not append the bump key"
pass
test "Generate a UUID"
./splinterctl uuid || fail "Did not generate a UUID"
pass
report