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 a5ef628
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
-
name: Unit tests
run: make test
-
-
name: Linter
run: make lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true
-
name: Vulnerability scan
run: make vulncheck
Expand All @@ -45,19 +49,23 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
-
name: Unit tests
run: make test
-
-
name: Linter
run: make lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true

test-macos:
name: Unit Tests macOS
Expand All @@ -67,13 +75,20 @@ jobs:
name: Checkout
uses: actions/checkout@v3
-
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
check-latest: ${{ env.CHECK_LATEST }}
cache: false
-
name: Pull dependencies
run: make install-go-modules
-
name: Unit tests
run: make test
-
name: Linter
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true
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 a5ef628

Please sign in to comment.