Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unit test failure on Windows #522

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ jobs:
go build -a -o _output/azurediskplugin.exe ./pkg/azurediskplugin
- name: Run Windows Unit Tests
run: |
go test -v -race ./pkg/mounter/...
go test -v -race ./pkg/util/...
go test -v -race ./pkg/csi-common/...
go test -v -race ./pkg/...
8 changes: 8 additions & 0 deletions pkg/azuredisk/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ import (
"io/ioutil"
"os"
"reflect"
"runtime"
"testing"
)

func skipIfTestingOnWindows(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping tests on Windows")
}
}

func TestGetCloudProvider(t *testing.T) {
skipIfTestingOnWindows(t)
fakeCredFile := "fake-cred-file.json"
fakeKubeConfig := "fake-kube-config"
emptyKubeConfig := "empty-kube-config"
Expand Down
1 change: 1 addition & 0 deletions pkg/azuredisk/azuredisk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ func TestIsAvailabilityZone(t *testing.T) {
}

func TestIsCorruptedDir(t *testing.T) {
skipIfTestingOnWindows(t)
existingMountPath, err := ioutil.TempDir(os.TempDir(), "csi-mount-test")
if err != nil {
t.Fatalf("failed to create tmp dir: %v", err)
Expand Down
7 changes: 7 additions & 0 deletions pkg/azuredisk/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func TestGetMaxDataDiskCount(t *testing.T) {
}

func TestEnsureMountPoint(t *testing.T) {
skipIfTestingOnWindows(t)
errorTarget := "./error_is_likely_target"
alreadyExistTarget := "./false_is_likely_exist_target"
azuredisk := "./azure.go"
Expand Down Expand Up @@ -326,6 +327,7 @@ func TestNodeStageVolume(t *testing.T) {
}

func TestNodeUnstageVolume(t *testing.T) {
skipIfTestingOnWindows(t)
errorTarget := "./error_is_likely_target"
targetFile := "./abc.go"
tests := []struct {
Expand Down Expand Up @@ -379,6 +381,7 @@ func TestNodeUnstageVolume(t *testing.T) {
}

func TestNodePublishVolume(t *testing.T) {
skipIfTestingOnWindows(t)
volumeCap := csi.VolumeCapability_AccessMode{Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER}
publishContext := map[string]string{
LUN: "/dev/01",
Expand Down Expand Up @@ -504,6 +507,7 @@ func TestNodePublishVolume(t *testing.T) {
}

func TestNodeUnpublishVolume(t *testing.T) {
skipIfTestingOnWindows(t)
errorTarget := "./error_is_likely_target"
targetFile := "./abc.go"
tests := []struct {
Expand Down Expand Up @@ -556,6 +560,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
}

func TestNodeExpandVolume(t *testing.T) {
skipIfTestingOnWindows(t)
d, _ := NewFakeDriver(t)
stdCapacityRange = &csi.CapacityRange{
RequiredBytes: volumehelper.GiBToBytes(15),
Expand Down Expand Up @@ -590,6 +595,7 @@ func TestNodeExpandVolume(t *testing.T) {
}

func TestGetBlockSizeBytes(t *testing.T) {
skipIfTestingOnWindows(t)
d, _ := NewFakeDriver(t)
testTarget := "./test"
tests := []struct {
Expand Down Expand Up @@ -622,6 +628,7 @@ func TestGetBlockSizeBytes(t *testing.T) {
}

func TestEnsureBlockTargetFile(t *testing.T) {
skipIfTestingOnWindows(t)
testTarget := "./test"
d, _ := NewFakeDriver(t)
tests := []struct {
Expand Down