Skip to content

Commit

Permalink
fix test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Aug 2, 2023
1 parent c1152a8 commit bee8a5d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions realpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/gandarez/go-realpath"
Expand Down Expand Up @@ -33,6 +34,10 @@ func TestRealpath_ZeroLenght(t *testing.T) {
}

func TestRealpath_NonFile(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("skipping test on windows platform")
}

wd, err := os.Getwd()
require.NoError(t, err)

Expand All @@ -41,6 +46,23 @@ func TestRealpath_NonFile(t *testing.T) {
assert.EqualError(t, err, fmt.Sprintf("lstat %s: no such file or directory", filepath.Join(wd, "non-file")))
}

func TestRealpath_NonFile_Windows(t *testing.T) {
if runtime.GOOS != "windows" {
t.Skip("skipping test on non-windows platform")
}

wd, err := os.Getwd()
require.NoError(t, err)

_, err = realpath.Realpath("non-file")

assert.EqualError(
t,
err,
fmt.Sprintf("CreateFile %s: The system cannot find the file specified.", filepath.Join(wd, "non-file")),
)
}

func TestRealpath_RelativePath(t *testing.T) {
path, err := realpath.Realpath("testdata/relative.go")
require.NoError(t, err)
Expand Down

0 comments on commit bee8a5d

Please sign in to comment.