Skip to content

Commit

Permalink
Fix windows error
Browse files Browse the repository at this point in the history
  • Loading branch information
toshimaru committed Aug 17, 2019
1 parent 8b3e3a2 commit ff2c9c5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"io/ioutil"
"os/exec"
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -42,7 +43,7 @@ func TestInvalidFilename(t *testing.T) {

assert.NotNil(t, err)
assert.NotNil(t, o.String())
assert.Contains(t, o.String(), "Error: open InvalidFilename: no such file or directory")
assert.Contains(t, o.String(), invalidFileErrorMsg())
}

func TestExecute(t *testing.T) {
Expand Down Expand Up @@ -80,7 +81,7 @@ func TestMultipleFilesWithInvalidFileError(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, o.String())
assert.Contains(t, o.String(), "[38;5;197mpackage")
assert.Contains(t, o.String(), "open InvalidFilename: no such file or directory")
assert.Contains(t, o.String(), invalidFileErrorMsg())
assert.Contains(t, o.String(), "This is dummy.")
}
func TestInvalidTheme(t *testing.T) {
Expand Down Expand Up @@ -218,3 +219,10 @@ func resetFlags() {
func resetTheme() {
theme = "monokai"
}

func invalidFileErrorMsg() string {
if runtime.GOOS == "windows" {
return "open InvalidFilename: The system cannot find the file specified."
}
return "open InvalidFilename: no such file or directory"
}

0 comments on commit ff2c9c5

Please sign in to comment.