-
Notifications
You must be signed in to change notification settings - Fork 10
/
pyrsia_cli.bats
173 lines (142 loc) · 4.8 KB
/
pyrsia_cli.bats
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/env bash
COMMON_SETUP='common-setup'
DOCKER_COMPOSE_DIR="$REPO_DIR/bats/tests/resources/docker/docker-compose_bootstrap.yml"
# Individual tests should timeout after 3 minutes
export BATS_TEST_TIMEOUT=60
setup_file() {
load $COMMON_SETUP
_common_setup_file "$DOCKER_COMPOSE_DIR"
}
teardown_file() {
load $COMMON_SETUP
_common_teardown_file
}
setup() {
load $COMMON_SETUP
_common_setup
PYRSIA_CLI="$PYRSIA_TARGET_DIR"/pyrsia
}
teardown() {
shopt -u nocasematch
run "$PYRSIA_CLI" config edit --host localhost --port 7888 --diskspace "10 GB"
}
@test "Testing 'pyrsia help' CLI, check if the help is shown." {
# ignore case in this @test
shopt -s nocasematch
# run pyrsia help
run "$PYRSIA_CLI" help
# check if pyrsia help is shown
assert_output --partial 'Usage:'
assert_output --partial 'Commands:'
assert_output --partial 'Options:'
# run pyrsia help
run "$PYRSIA_CLI" -h
# check if pyrsia help is shown
assert_output --partial 'Usage:'
assert_output --partial 'Commands:'
assert_output --partial 'Options:'
}
@test "Testing 'pyrsia ping' CLI, check if the node is up and reachable." {
# run pyrsia ping
run "$PYRSIA_CLI" ping
# check if pyrsia ping returns errors
refute_output --partial 'Error'
}
@test "Testing 'pyrsia status' CLI, check if the node is connected to peers." {
# run pyrsia status
run "$PYRSIA_CLI" status
# check if pyrsia node has peers, fail if doesn't or error
refute_output --partial '0'
refute_output --partial 'Error'
}
@test "Testing 'pyrsia list' CLI, check if the node returns the list of peers." {
# run pyrsia list
run "$PYRSIA_CLI" list
# Fail if the list is empty or error
refute_output --partial '[]'
refute_output --partial 'Error'
# run pyrsia list
run "$PYRSIA_CLI" -l
# Fail if the list is empty or error
refute_output --partial '[]'
refute_output --partial 'Error'
}
@test "Testing 'pyrsia config' CLI, check if the config can be changed and shown." {
# change hostname
run "$PYRSIA_CLI" config edit --host host.for.test
assert_output --partial 'Node configuration Saved'
# change port
run "$PYRSIA_CLI" config -e --port 9999
assert_output --partial 'Node configuration Saved'
# change diskspace
run "$PYRSIA_CLI" -c edit --diskspace "5 GB"
assert_output --partial 'Node configuration Saved'
run "$PYRSIA_CLI" config --show
assert_output --partial 'host.for.test'
assert_output --partial '9999'
assert_output --partial '5 GB'
# change two or more values at once
run "$PYRSIA_CLI" -c -e --host 192.168.0.0 --port 8888 --diskspace "3 GB"
assert_output --partial 'Node configuration Saved'
run "$PYRSIA_CLI" -c --show
assert_output --partial '192.168.0.0'
assert_output --partial '8888'
assert_output --partial '3 GB'
}
@test "Testing 'pyrsia config edit' CLI, check if input values are validated." {
run "$PYRSIA_CLI" config edit --host .some.localhost --port 65536 --diskspace "10GB"
assert_output --partial 'Invalid value for Hostname'
assert_output --partial 'Invalid value for Port Number'
assert_output --partial 'Invalid value for Disk Allocation'
run "$PYRSIA_CLI" -c -s
assert_output --partial 'localhost'
assert_output --partial '7888'
assert_output --partial '10 GB'
}
@test "Testing 'pyrsia version', check if the CLI version shows." {
# run pyrsia version
run "$PYRSIA_CLI" --version
# check if the CLI version shows
assert_output --partial 'pyrsia_cli'
# run pyrsia version
run "$PYRSIA_CLI" -V
# check if the CLI version shows
assert_output --partial 'pyrsia_cli'
}
@test "Testing 'pyrsia build' help options, check if the build help is shown." {
# run pyrsia build help
run "$PYRSIA_CLI" build
# check if the BUILD help is shown
assert_output --partial 'docker'
assert_output --partial 'maven'
# run pyrsia build help
run "$PYRSIA_CLI" -b
# check if the BUILD help is shown
assert_output --partial 'docker'
assert_output --partial 'maven'
# run pyrsia build help
run "$PYRSIA_CLI" -b -h
# check if the BUILD help is shown
assert_output --partial 'docker'
assert_output --partial 'maven'
}
@test "Testing 'pyrsia inspect-log' help/options, check if the inspect-log help is shown." {
# run pyrsia inspect log help
run "$PYRSIA_CLI" inspect-log -h
# check if the INSPECT-LOG help is shown
assert_output --partial 'docker'
assert_output --partial 'maven'
run "$PYRSIA_CLI" inspect-log
# check if the INSPECT-LOG help is shown
assert_output --partial 'docker'
assert_output --partial 'maven'
}
@test "Testing 'pyrsia authorize' help/options, check if the authorize help is shown." {
# run pyrsia authorize log help
run "$PYRSIA_CLI" authorize -h
# check if the authorize help is shown
assert_output --partial 'peer'
run "$PYRSIA_CLI" authorize
# check if the authorize help is shown
assert_output --partial 'peer'
}