aboutsummaryrefslogtreecommitdiffhomepage
path: root/test.bats
diff options
context:
space:
mode:
Diffstat (limited to 'test.bats')
-rw-r--r--test.bats78
1 files changed, 78 insertions, 0 deletions
diff --git a/test.bats b/test.bats
new file mode 100644
index 0000000..0316236
--- /dev/null
+++ b/test.bats
@@ -0,0 +1,78 @@
1#!/usr/bin/env bats
2
3export TOOL_NAME='gist'
4export GIST_USER='phamhsieh'
5export GIST_API_TOKEN='dd43dc9949a5b4a1d6c7''b779f13af357282016e4'
6
7@test "Testing ${TOOL_NAME} tool" {
8 echo "${TOOL_NAME}"
9}
10
11@test "The help command should print usage" {
12 run ./gist help
13
14 [[ "$status" -eq 0 ]]
15 [[ "${lines[0]}" = "${TOOL_NAME}" ]]
16}
17
18@test "Use config command to add configuarion for user" {
19 run ./gist config user ${GIST_USER}
20 [ "$status" -eq 0 ]
21 [ "${lines[0]}" = "user='${GIST_USER}'" ]
22}
23
24@test "Use config command to add configuarion for token" {
25 run ./gist config token ${GIST_API_TOKEN}
26 [ "$status" -eq 0 ]
27 [ "${lines[0]}" = "token=${GIST_API_TOKEN}" ]
28}
29
30@test "The new command should create a new public gist with gist command" {
31 hint=false run ./gist new --file gist --desc 'Manage gist like a pro' gist
32 [ "$status" -eq 0 ]
33 [[ "${lines[-1]}" =~ ([0-9]+ +https://gist.github.com/[0-9a-z]+) ]]
34}
35
36@test "The fetch command should fetch user gists" {
37 hint=false run ./gist fetch
38 [ "$status" -eq 0 ]
39 [[ "${lines[-1]}" =~ ([0-9]+ +https://gist.github.com/[0-9a-z]+) ]]
40}
41
42@test "The fetch command should fetch starred gists" {
43 hint=false run ./gist fetch star
44 [ "$status" -eq 0 ]
45 echo ${lines[-1]}
46 [[ "${lines[-1]}" =~ (Not a single valid gist|^ *s[0-9]+ +https://gist.github.com/[0-9a-z]+) ]]
47}
48
49@test "No arguments prints the list of gists" {
50 hint=false run ./gist
51 [ "$status" -eq 0 ]
52 [[ "${lines[-1]}" =~ ([0-9]+ +https://gist.github.com/[0-9a-z]+) ]]
53}
54
55@test "Specify an index to return the path of cloned repo" {
56 run ./gist 1 --no-action
57 [ "$status" -eq 0 ]
58 [[ "${lines[-1]}" =~ (${HOME}/gist/[0-9a-z]+) ]]
59}
60
61@test "The edit command should modify the description of a gist" {
62 ./gist edit 1 "Modified description"
63 run ./gist detail 1
64 [ "$status" -eq 0 ]
65 [[ "${lines[0]}" =~ (Modified description$) ]]
66}
67
68@test "The delete command should delete specified gists" {
69 run ./gist delete 1 --force
70 [ "$status" -eq 0 ]
71 [ "${lines[0]}" = '1 deleted' ]
72}
73
74@test "The user command should get the list of public gists from a user" {
75 run ./gist user defunkt
76 [ "$status" -eq 0 ]
77 [[ "${lines[0]}" =~ (https://gist.github.com/[0-9a-z]+ defunkt) ]]
78}