Skip to content

Commit

Permalink
fix(remove): Comments, cleanups, improve tests for remove
Browse files Browse the repository at this point in the history
  • Loading branch information
dustmop committed Nov 11, 2019
1 parent 67f5ad5 commit 4c1a8c1
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
12 changes: 6 additions & 6 deletions cmd/fsi_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,25 @@ func (fr *FSITestRunner) GetCommandOutput() string {
}

// MustExec runs a command, returning standard output, failing the test if there's an error
func (fr *FSITestRunner) MustExec(cmdText string) string {
func (fr *FSITestRunner) MustExec(t *testing.T, cmdText string) string {
if err := fr.ExecCommand(cmdText); err != nil {
fr.RepoRoot.t.Fatal(err)
t.Fatal(err)
}
return fr.GetCommandOutput()
}

// MustWriteFile writes to a file, failing the test if there's an error
func (fr *FSITestRunner) MustWriteFile(filename, contents string) {
func (fr *FSITestRunner) MustWriteFile(t *testing.T, filename, contents string) {
if err := ioutil.WriteFile(filename, []byte(contents), os.FileMode(0644)); err != nil {
fr.RepoRoot.t.Fatal(err)
t.Fatal(err)
}
}

// MustReadFile reads a file, failing the test if there's an error
func (fr *FSITestRunner) MustReadFile(filename string) string {
func (fr *FSITestRunner) MustReadFile(t *testing.T, filename string) string {
bytes, err := ioutil.ReadFile(filename)
if err != nil {
fr.RepoRoot.t.Fatal(err)
t.Fatal(err)
}
return string(bytes)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/log_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cmd

import (
"context"
"time"
"testing"
"time"

"github.com/qri-io/qri/base/dsfs"
"github.com/spf13/cobra"
Expand Down
5 changes: 3 additions & 2 deletions cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/qri-io/ioes"
"github.com/qri-io/qri/dsref"
"github.com/qri-io/qri/lib"
"github.com/qri-io/qri/repo"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -44,7 +45,7 @@ both qri & IPFS. Promise.`,

cmd.Flags().StringVarP(&o.RevisionsText, "revisions", "r", "", "revisions to delete")
cmd.Flags().BoolVarP(&o.All, "all", "a", false, "synonym for --revisions=all")
cmd.Flags().BoolVar(&o.KeepFiles, "keep-files", false, "")
cmd.Flags().BoolVar(&o.KeepFiles, "keep-files", false, "don't modify files in working directory")

return cmd
}
Expand Down Expand Up @@ -112,7 +113,7 @@ func (o *RemoveOptions) Run() (err error) {

res := lib.RemoveResponse{}
if err = o.DatasetRequests.Remove(&params, &res); err != nil {
if err.Error() == "repo: not found" {
if err == repo.ErrNotFound {
return lib.NewError(err, fmt.Sprintf("could not find dataset '%s'", o.Refs.Ref()))
}
return err
Expand Down
Loading

0 comments on commit 4c1a8c1

Please sign in to comment.