Skip to content

Commit 9488ab3

Browse files
committed
fix: fails unit-test and enable unit-test on CI
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
1 parent ccf133c commit 9488ab3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.github/workflows/driver.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
with:
1414
go-version: "^1.15"
1515
- name: Run tests
16-
run: go test ./main_test.go
16+
run: go test ./...
1717
- name: Run vetting/linting checks
1818
run: go vet ./...
1919
build:

pkg/driver/node_server_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package driver_test
33
import (
44
"context"
55
"os"
6+
"path"
67
"testing"
78

89
"github.com/civo/civo-csi/pkg/driver"
@@ -115,10 +116,12 @@ func TestNodePublishVolume(t *testing.T) {
115116
hotPlugger := &driver.FakeDiskHotPlugger{}
116117
d.DiskHotPlugger = hotPlugger
117118

119+
targetPath := path.Join(t.TempDir(), "some-path")
120+
118121
_, err := d.NodePublishVolume(context.Background(), &csi.NodePublishVolumeRequest{
119122
VolumeId: "volume-1",
120123
StagingTargetPath: "/mnt/my-target",
121-
TargetPath: "/var/lib/kubelet/some-path",
124+
TargetPath: targetPath,
122125
VolumeCapability: &csi.VolumeCapability{
123126
AccessType: &csi.VolumeCapability_Mount{},
124127
AccessMode: &csi.VolumeCapability_AccessMode{
@@ -128,7 +131,7 @@ func TestNodePublishVolume(t *testing.T) {
128131
})
129132
assert.Nil(t, err)
130133

131-
mounted, _ := d.DiskHotPlugger.IsMounted("")
134+
mounted, _ := d.DiskHotPlugger.IsMounted(targetPath)
132135
assert.True(t, mounted)
133136
})
134137
}
@@ -144,13 +147,15 @@ func TestNodeUnpublishVolume(t *testing.T) {
144147
}
145148
d.DiskHotPlugger = hotPlugger
146149

150+
targetPath := path.Join(t.TempDir(), "some-path")
151+
147152
_, err := d.NodeUnpublishVolume(context.Background(), &csi.NodeUnpublishVolumeRequest{
148153
VolumeId: "volume-1",
149-
TargetPath: "/var/lib/kubelet/some-path",
154+
TargetPath: targetPath,
150155
})
151156
assert.Nil(t, err)
152157

153-
mounted, _ := d.DiskHotPlugger.IsMounted("/var/lib/kubelet/some-path")
158+
mounted, _ := d.DiskHotPlugger.IsMounted(targetPath)
154159
assert.False(t, mounted)
155160
})
156161
}

0 commit comments

Comments
 (0)