Skip to content

Commit

Permalink
test: sharness tests for ipfs version deps
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Apr 4, 2019
1 parent c15dd37 commit 499d82f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/commands/version.go
Expand Up @@ -96,6 +96,8 @@ type Dependency struct {
Sum string
}

const pkgVersionFmt = "%s@%s"

var depsVersionCommand = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Shows information about dependencies used for build",
Expand All @@ -114,7 +116,7 @@ Print out all dependencies and their versions.`,
dep.Version = mod.Version
dep.Sum = mod.Sum
if repl := mod.Replace; repl != nil {
dep.ReplacedBy = fmt.Sprintf("%s@%s", repl.Path, repl.Version)
dep.ReplacedBy = fmt.Sprintf(pkgVersionFmt, repl.Path, repl.Version)
}
return
}
Expand All @@ -130,7 +132,7 @@ Print out all dependencies and their versions.`,
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, dep Dependency) error {
fmt.Fprintf(w, "%s@%s", dep.Path, dep.Version)
fmt.Fprintf(w, pkgVersionFmt, dep.Path, dep.Version)
if dep.ReplacedBy != "" {
fmt.Fprintf(w, " => %s", dep.ReplacedBy)
}
Expand Down
9 changes: 9 additions & 0 deletions test/sharness/t0010-basic-commands.sh
Expand Up @@ -41,6 +41,15 @@ test_expect_success "ipfs version --all has all required fields" '
grep "Golang version" version_all.txt
'

test_expect_success "ipfs version deps succeeds" '
ipfs version deps >deps.txt
'

test_expect_success "ipfs version deps output looks good" '
head -1 deps.txt | grep "go-ipfs (devel)" &&
[[ $(tail -n +2 | egrep -v -c "^[^ @]+@v[^ @]+( => [^ @]+@v[^ @]+)?$") -eq 0 ]] ||
'

test_expect_success "'ipfs commands' succeeds" '
ipfs commands >commands.txt
'
Expand Down
10 changes: 10 additions & 0 deletions test/sharness/t0060-daemon.sh
Expand Up @@ -71,6 +71,16 @@ test_expect_success "ipfs version output looks good" '
test_fsh cat version.txt
'

test_expect_success "ipfs version deps succeeds" '
ipfs version deps >deps.txt
'

test_expect_success "ipfs version deps output looks good" '
head -1 deps.txt | grep "go-ipfs@(devel)" &&
[[ $(tail -n +2 | egrep -v -c "^[^ @]+@v[^ @]+( => [^ @]+@v[^ @]+)?$") -eq 0 ]] ||
test_fsh cat deps.txt
'

test_expect_success "ipfs help succeeds" '
ipfs help >help.txt
'
Expand Down

0 comments on commit 499d82f

Please sign in to comment.