diff --git a/cmd/transpile/main.go b/cmd/transpile/main.go index 58a0bdb..f225464 100644 --- a/cmd/transpile/main.go +++ b/cmd/transpile/main.go @@ -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 { diff --git a/cmd/transpile/main_test.go b/cmd/transpile/main_test.go index e501337..042795a 100644 --- a/cmd/transpile/main_test.go +++ b/cmd/transpile/main_test.go @@ -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) + } +}