From e07a4f18c538b0439af0deb0c1c9a623388d32b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Henrique=20Guard=C3=A3o=20Gandarez?= Date: Wed, 2 Aug 2023 10:10:13 -0300 Subject: [PATCH] Fix test on windows --- .github/workflows/on_push.yml | 28 +++++++++++++++++++++++----- realpath_test.go | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.github/workflows/on_push.yml b/.github/workflows/on_push.yml index b5bb87e..e84331d 100644 --- a/.github/workflows/on_push.yml +++ b/.github/workflows/on_push.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/realpath_test.go b/realpath_test.go index e99faea..16ab365 100644 --- a/realpath_test.go +++ b/realpath_test.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "testing" "github.com/gandarez/go-realpath" @@ -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) @@ -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)