Skip to content

Commit 8dcc490

Browse files
tests: enable windows unit tests
Signed-off-by: Mayank Shah <[email protected]>
1 parent 4332a49 commit 8dcc490

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

.github/workflows/windows.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Windows Test
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
branches: [ master ]
7+
jobs:
8+
build:
9+
strategy:
10+
matrix:
11+
go-versions: [1.13.x]
12+
platform: [windows-latest]
13+
runs-on: ${{ matrix.platform }}
14+
steps:
15+
- name: Install Go
16+
uses: actions/setup-go@v1
17+
with:
18+
go-version: ${{ matrix.go-version }}
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
- name: Run Windows Unit Tests
22+
run: |
23+
go test -v -race ./pkg/...

pkg/blob/nodeserver_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"os"
2424
"reflect"
25+
"runtime"
2526
"syscall"
2627
"testing"
2728

@@ -125,7 +126,13 @@ func TestEnsureMountPoint(t *testing.T) {
125126

126127
func TestNodePublishVolume(t *testing.T) {
127128
volumeCap := csi.VolumeCapability_AccessMode{Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER}
128-
129+
createDirError := status.Errorf(codes.Internal,
130+
"Could not mount target \"./azure.go\": mkdir ./azure.go: not a directory")
131+
if runtime.GOOS == "windows" {
132+
createDirError = status.Errorf(codes.Internal,
133+
"Could not mount target \"./azure.go\": mkdir ./azure.go: "+
134+
"The system cannot find the path specified.")
135+
}
129136
tests := []struct {
130137
desc string
131138
req csi.NodePublishVolumeRequest
@@ -170,7 +177,7 @@ func TestNodePublishVolume(t *testing.T) {
170177
TargetPath: "./azure.go",
171178
StagingTargetPath: sourceTest,
172179
Readonly: true},
173-
expectedErr: status.Errorf(codes.Internal, "Could not mount target \"./azure.go\": mkdir ./azure.go: not a directory"),
180+
expectedErr: createDirError,
174181
},
175182
{
176183
desc: "Error mounting resource busy",
@@ -198,7 +205,7 @@ func TestNodePublishVolume(t *testing.T) {
198205
_, err := d.NodePublishVolume(context.Background(), &test.req)
199206

200207
if !reflect.DeepEqual(err, test.expectedErr) {
201-
t.Errorf("Unexpected error: %v", err)
208+
t.Errorf("Desc: %s - Unexpected error: %v - Expected: %v", test.desc, err, test.expectedErr)
202209
}
203210
}
204211

0 commit comments

Comments
 (0)