#!/bin/sh # # MIT Licensed # test_description="Test ctl installation and some basic commands" . lib/test-lib.sh test_expect_success "current dir is writeable" ' echo "Writability check" >test.txt ' test_expect_success "cluster-ctl --version succeeds" ' ipfs-cluster-ctl --version >version.txt ' test_expect_success "cluster-ctl --version output looks good" ' egrep "^ipfs-cluster-ctl version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null || test_fsh cat version.txt ' test_expect_success "cluster-ctl --help and -h succeed" ' ipfs-cluster-ctl --help >help.txt && ipfs-cluster-ctl -h >help.txt ' test_expect_success "cluster-ctl help and h succeed" ' ipfs-cluster-ctl h >help.txt && ipfs-cluster-ctl help >help.txt ' 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 || test_fsh cat help.txt help1.txt help2.txt help3.txt ' test_expect_success "cluster-ctl help output looks good" ' egrep -i "^Usage" help.txt >/dev/null && egrep -i "^Commands" help.txt >/dev/null && egrep -i "^Global Options" help.txt >/dev/null ' test_expect_success "cluster-ctl commands succeeds" ' ipfs-cluster-ctl commands >unfmt_commands.txt && awk ''NF'' unfmt_commands.txt >commands.txt ' test_expect_success "cluster-ctl commands output looks good" ' 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 ' test_expect_success "All commands accept --help" ' echo 0 > fail while read -r cmd do $cmd --help /dev/null || { echo $cmd does not accept --help; echo 1 > fail; } done 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