mirror of https://github.com/dirtbags/moth.git
Attempt to reproduce #154
This commit is contained in:
parent
ce037ebca3
commit
6f1f889be7
|
@ -81,7 +81,7 @@ func (t *T) ParseArgs() (Command, error) {
|
|||
default:
|
||||
fmt.Fprintln(t.Stderr, "ERROR:", t.Args[1], "is not a valid command")
|
||||
usage(t.Stderr)
|
||||
return nothing, fmt.Errorf("Invalid command")
|
||||
return nothing, fmt.Errorf("invalid command")
|
||||
}
|
||||
|
||||
if err := flags.Parse(t.Args[2:]); err != nil {
|
||||
|
|
|
@ -4,7 +4,9 @@ import (
|
|||
"archive/zip"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -202,3 +204,32 @@ func TestFilesystem(t *testing.T) {
|
|||
t.Error("Wrong file pulled", stdout.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestCwd(t *testing.T) {
|
||||
testwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Error("Can't get current working directory!")
|
||||
return
|
||||
}
|
||||
defer os.Chdir(testwd)
|
||||
|
||||
stdin := new(bytes.Buffer)
|
||||
stdout := new(bytes.Buffer)
|
||||
stderr := new(bytes.Buffer)
|
||||
tp := T{
|
||||
Stdin: stdin,
|
||||
Stdout: stdout,
|
||||
Stderr: stderr,
|
||||
BaseFs: afero.NewOsFs(),
|
||||
}
|
||||
|
||||
stdout.Reset()
|
||||
os.Chdir("/")
|
||||
if err := tp.Run(
|
||||
"file",
|
||||
fmt.Sprintf("-dir=%s/testdata/cat1/1", testwd),
|
||||
"moo.txt",
|
||||
); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue