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 2e8ead8 commit 6df47cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/commands/version.go
Original file line number Diff line number Diff line change
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
10 changes: 10 additions & 0 deletions test/sharness/t0010-basic-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ 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_fsh cat deps.txt
'

test_expect_success "'ipfs commands' succeeds" '
ipfs commands >commands.txt
'
Expand Down
10 changes: 10 additions & 0 deletions test/sharness/t0060-daemon.sh
Original file line number Diff line number Diff line change
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 6df47cb

Please sign in to comment.