2017-04-18 22:22:05 +00:00
|
|
|
#!/bin/sh
|
2017-04-28 03:20:29 +00:00
|
|
|
#
|
|
|
|
# MIT Licensed
|
|
|
|
#
|
2017-04-18 22:22:05 +00:00
|
|
|
|
|
|
|
test_description="Test ctl installation and some basic commands"
|
|
|
|
|
|
|
|
. lib/test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success "current dir is writeable" '
|
2017-04-28 03:20:29 +00:00
|
|
|
echo "Writability check" >test.txt
|
2017-04-18 22:22:05 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "cluster-ctl --version succeeds" '
|
2017-04-28 03:20:29 +00:00
|
|
|
ipfs-cluster-ctl --version >version.txt
|
2017-04-18 22:22:05 +00:00
|
|
|
'
|
|
|
|
|
2017-04-28 03:20:29 +00:00
|
|
|
test_expect_success "cluster-ctl --version output looks good" '
|
|
|
|
egrep "^ipfs-cluster-ctl version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null &&
|
|
|
|
rm version.txt
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "cluster-ctl --help and -h succeed" '
|
2017-04-19 00:10:45 +00:00
|
|
|
ipfs-cluster-ctl --help &&
|
2017-04-28 03:20:29 +00:00
|
|
|
ipfs-cluster-ctl -h
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "cluster-ctl help and h succeed" '
|
2017-04-19 00:10:45 +00:00
|
|
|
ipfs-cluster-ctl h &&
|
|
|
|
ipfs-cluster-ctl help
|
2017-04-18 22:22:05 +00:00
|
|
|
'
|
2017-05-02 20:32:42 +00:00
|
|
|
|
2017-04-28 03:20:29 +00:00
|
|
|
test_expect_success "All help options match" '
|
|
|
|
ipfs-cluster-ctl help >help.txt &&
|
|
|
|
ipfs-cluster-ctl h >help1.txt &&
|
|
|
|
ipfs-cluster-ctl --help >help2.txt &&
|
|
|
|
ipfs-cluster-ctl --h >help3.txt &&
|
|
|
|
diff help.txt help1.txt &&
|
|
|
|
diff help.txt help2.txt &&
|
|
|
|
diff help.txt help3.txt &&
|
|
|
|
rm help1.txt help2.txt help3.txt
|
2017-05-02 20:32:42 +00:00
|
|
|
'
|
2017-04-18 22:22:05 +00:00
|
|
|
|
|
|
|
test_expect_success "cluster-ctl help output looks good" '
|
2017-04-28 03:20:29 +00:00
|
|
|
egrep -i "^Usage" help.txt >/dev/null &&
|
|
|
|
egrep -i "^Commands" help.txt >/dev/null &&
|
|
|
|
egrep -i "^Global Options" help.txt >/dev/null &&
|
|
|
|
rm help.txt
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "cluster-ctl commands succeeds" '
|
|
|
|
ipfs-cluster-ctl commands >unfmt_commands.txt &&
|
|
|
|
awk ''NF'' unfmt_commands.txt >commands.txt
|
2017-04-18 22:22:05 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "cluster-ctl commands output looks good" '
|
2017-04-28 03:20:29 +00:00
|
|
|
grep "ipfs-cluster-ctl id" commands.txt &&
|
|
|
|
grep "ipfs-cluster-ctl peers" commands.txt &&
|
|
|
|
grep "ipfs-cluster-ctl pin" commands.txt &&
|
|
|
|
grep "ipfs-cluster-ctl status" commands.txt &&
|
|
|
|
grep "ipfs-cluster-ctl sync" commands.txt &&
|
|
|
|
grep "ipfs-cluster-ctl recover" commands.txt &&
|
|
|
|
grep "ipfs-cluster-ctl version" commands.txt &&
|
|
|
|
grep "ipfs-cluster-ctl commands" commands.txt
|
2017-04-18 22:22:05 +00:00
|
|
|
'
|
|
|
|
|
2017-04-28 03:20:29 +00:00
|
|
|
test_expect_success "All commands accept --help" '
|
|
|
|
echo 0 > fail
|
|
|
|
while read -r cmd
|
|
|
|
do
|
|
|
|
$cmd --help </dev/null >/dev/null ||
|
|
|
|
{ echo $cmd does not accept --help; echo 1 > fail; }
|
2017-05-02 20:32:42 +00:00
|
|
|
done <commands.txt
|
2017-04-18 22:22:05 +00:00
|
|
|
|
2017-04-28 03:20:29 +00:00
|
|
|
if [$(cat fail) = 1 ]; then
|
2017-05-02 20:32:42 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2017-04-18 22:22:05 +00:00
|
|
|
'
|
2017-04-28 03:20:29 +00:00
|
|
|
|
|
|
|
test_expect_success "All cluster-ctl command docs are 80 columns or less" '
|
|
|
|
echo 0 > failure
|
|
|
|
while read cmd
|
|
|
|
do
|
|
|
|
LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -1)"
|
|
|
|
[ $LENGTH -gt 80 ] &&
|
|
|
|
{ echo "$cmd" help text is longer than 79 chars "($LENGTH)"; echo 1 > failure; }
|
|
|
|
done <commands.txt
|
|
|
|
|
|
|
|
if [ $(cat failure) = 1 ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
rm commands.txt
|
|
|
|
'
|
2017-04-18 22:22:05 +00:00
|
|
|
test_done
|
|
|
|
|