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 e07a4f1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ 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
Expand All @@ -33,6 +34,12 @@ jobs:
-
name: Linter
run: make lint
-
name: Linter
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true
-
name: Vulnerability scan
run: make vulncheck
Expand All @@ -45,19 +52,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 +78,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 e07a4f1

Please sign in to comment.