Skip to content

Commit ac86adb

Browse files
authored
Merge pull request #104 from andyzhangx/win-ut
test: fix windows unit test
2 parents cf25556 + bfc941f commit ac86adb

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ https://git.k8s.io/community/contributors/devel/release.md#issue-kind-label
1414
<!--
1515
Add one of the following kinds:
1616
/kind bug
17-
/kind test
1817
/kind cleanup
1918
/kind documentation
2019
/kind feature

.github/workflows/windows.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,4 @@ jobs:
2525
go build -a -o _output/smbplugin.exe ./pkg/smbplugin
2626
- name: Run Windows Unit Tests
2727
run: |
28-
go test -v -race ./pkg/smb/...
29-
go test -v -race ./pkg/csi-common/...
30-
go test -v -race ./pkg/mounter/...
28+
go test -v -race ./pkg/...

pkg/smb/nodeserver_test.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"fmt"
2323
"os"
2424
"reflect"
25-
"runtime"
2625
"syscall"
2726
"testing"
2827

@@ -38,15 +37,8 @@ const (
3837
targetTest = "./target_test"
3938
)
4039

41-
// skip test if running on windows
42-
func skipTestIfWindows(t *testing.T) {
43-
if runtime.GOOS == "windows" {
44-
t.Skip("Skipping test on Windows")
45-
}
46-
}
47-
4840
func TestNodeStageVolume(t *testing.T) {
49-
skipTestIfWindows(t)
41+
skipIfTestingOnWindows(t)
5042

5143
stdVolCap := csi.VolumeCapability{
5244
AccessType: &csi.VolumeCapability_Mount{
@@ -190,7 +182,7 @@ func TestNodeExpandVolume(t *testing.T) {
190182
}
191183

192184
func TestNodePublishVolume(t *testing.T) {
193-
skipTestIfWindows(t)
185+
skipIfTestingOnWindows(t)
194186
volumeCap := csi.VolumeCapability_AccessMode{Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER}
195187
errorMountSource := "./error_mount_source"
196188
alreadyMountedTarget := "./false_is_likely_exist_target"
@@ -294,7 +286,7 @@ func TestNodePublishVolume(t *testing.T) {
294286
}
295287

296288
func TestNodeUnpublishVolume(t *testing.T) {
297-
skipTestIfWindows(t)
289+
skipIfTestingOnWindows(t)
298290
errorTarget := "./error_is_likely_target"
299291
targetFile := "./abc.go"
300292

@@ -346,7 +338,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
346338
}
347339

348340
func TestNodeUnstageVolume(t *testing.T) {
349-
skipTestIfWindows(t)
341+
skipIfTestingOnWindows(t)
350342
errorTarget := "./error_is_likely_target"
351343
targetFile := "./abc.go"
352344

pkg/smb/smb_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"io/ioutil"
2121
"os"
2222
"path/filepath"
23+
"runtime"
2324
"testing"
2425

2526
"github.com/stretchr/testify/assert"
@@ -30,10 +31,7 @@ const (
3031
)
3132

3233
func NewFakeDriver() *Driver {
33-
34-
driver := NewDriver(fakeNodeID)
35-
36-
return driver
34+
return NewDriver(fakeNodeID)
3735
}
3836

3937
func TestNewFakeDriver(t *testing.T) {
@@ -42,8 +40,15 @@ func TestNewFakeDriver(t *testing.T) {
4240
assert.NotNil(t, d)
4341
}
4442

43+
// skip test if running on windows
44+
func skipIfTestingOnWindows(t *testing.T) {
45+
if runtime.GOOS == "windows" {
46+
t.Skip("Skipping test on Windows")
47+
}
48+
}
49+
4550
func TestIsCorruptedDir(t *testing.T) {
46-
skipTestIfWindows(t)
51+
skipIfTestingOnWindows(t)
4752
existingMountPath, err := ioutil.TempDir(os.TempDir(), "csi-mount-test")
4853
if err != nil {
4954
t.Fatalf("failed to create tmp dir: %v", err)

0 commit comments

Comments
 (0)