@cryptotaxi247 / kubo / commits / aa55ab7af

test: sharness tests for ipfs version deps

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Mar 27, 2019 at 20:21 UTC aa55ab7af4352e3fe5f3e15061690e81ca7ac502
3 files changed +26 -3
core/commands/version.go
+4 -2
@@ -96,6 +96,8 @@ type Dependency struct {
96 Sum string
97 }
98
99 +const pkgVersionFmt = "%s@%s"
100 +
101 var depsVersionCommand = &cmds.Command{
102 Helptext: cmdkit.HelpText{
103 Tagline: "Shows information about dependencies used for build",
@@ -114,7 +116,7 @@ Print out all dependencies and their versions.`,
116 dep.Version = mod.Version
117 dep.Sum = mod.Sum
118 if repl := mod.Replace; repl != nil {
117 - dep.ReplacedBy = fmt.Sprintf("%s@%s", repl.Path, repl.Version)
119 + dep.ReplacedBy = fmt.Sprintf(pkgVersionFmt, repl.Path, repl.Version)
120 }
121 return
122 }
@@ -130,7 +132,7 @@ Print out all dependencies and their versions.`,
132 },
133 Encoders: cmds.EncoderMap{
134 cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, dep Dependency) error {
133 - fmt.Fprintf(w, "%s@%s", dep.Path, dep.Version)
135 + fmt.Fprintf(w, pkgVersionFmt, dep.Path, dep.Version)
136 if dep.ReplacedBy != "" {
137 fmt.Fprintf(w, " => %s", dep.ReplacedBy)
138 }
test/sharness/t0010-basic-commands.sh
+12 -1
@@ -41,6 +41,16 @@ test_expect_success "ipfs version --all has all required fields" '
41 grep "Golang version" version_all.txt
42 '
43
44 +test_expect_success "ipfs version deps succeeds" '
45 + ipfs version deps >deps.txt
46 +'
47 +
48 +test_expect_success "ipfs version deps output looks good" '
49 + head -1 deps.txt | grep "go-ipfs@(devel)" &&
50 + [[ $(tail -n +2 deps.txt | egrep -v -c "^[^ @]+@v[^ @]+( => [^ @]+@v[^ @]+)?$") -eq 0 ]] ||
51 + test_fsh cat deps.txt
52 +'
53 +
54 test_expect_success "'ipfs commands' succeeds" '
55 ipfs commands >commands.txt
56 '
@@ -83,6 +93,7 @@ test_expect_success "All commands accept --help" '
93
94 test_expect_failure "All ipfs root commands are mentioned in base helptext" '
95 echo 0 > fail
96 + ipfs --help > help.txt
97 cut -d" " -f 2 commands.txt | grep -v ipfs | sort -u | \
98 while read cmd
99 do
@@ -113,7 +124,7 @@ test_expect_success "All ipfs commands fail when passed a bad flag" '
124 echo 0 > fail
125 while read -r cmd
126 do
116 - test_must_fail $cmd --badflag >/dev/null ||
127 + test_must_fail $cmd --badflag >/dev/null 2>&1 ||
128 { echo "$cmd exit with code 0 when passed --badflag"; echo 1 > fail; }
129 done <commands.txt
130
test/sharness/t0060-daemon.sh
+10
@@ -71,6 +71,16 @@ test_expect_success "ipfs version output looks good" '
71 test_fsh cat version.txt
72 '
73
74 +test_expect_success "ipfs version deps succeeds" '
75 + ipfs version deps >deps.txt
76 +'
77 +
78 +test_expect_success "ipfs version deps output looks good" '
79 + head -1 deps.txt | grep "go-ipfs@(devel)" &&
80 + [[ $(tail -n +2 deps.txt | egrep -v -c "^[^ @]+@v[^ @]+( => [^ @]+@v[^ @]+)?$") -eq 0 ]] ||
81 + test_fsh cat deps.txt
82 +'
83 +
84 test_expect_success "ipfs help succeeds" '
85 ipfs help >help.txt
86 '