Skip to content

Commit

Permalink
Merge pull request #27 from civo/fix/unit-test-error
Browse files Browse the repository at this point in the history
Fix errors in existing Unit Tests on Local environment
  • Loading branch information
hlts2 authored Nov 8, 2024
2 parents eef1a8b + 1c142d6 commit b7261a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/driver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
go-version: "^1.15"
- name: Run tests
run: go test ./main_test.go
run: go test ./...
- name: Run vetting/linting checks
run: go vet ./...
build:
Expand Down
13 changes: 9 additions & 4 deletions pkg/driver/node_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package driver_test
import (
"context"
"os"
"path"
"testing"

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

targetPath := path.Join(t.TempDir(), "some-path")

_, err := d.NodePublishVolume(context.Background(), &csi.NodePublishVolumeRequest{
VolumeId: "volume-1",
StagingTargetPath: "/mnt/my-target",
TargetPath: "/var/lib/kubelet/some-path",
TargetPath: targetPath,
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{},
AccessMode: &csi.VolumeCapability_AccessMode{
Expand All @@ -128,7 +131,7 @@ func TestNodePublishVolume(t *testing.T) {
})
assert.Nil(t, err)

mounted, _ := d.DiskHotPlugger.IsMounted("")
mounted, _ := d.DiskHotPlugger.IsMounted(targetPath)
assert.True(t, mounted)
})
}
Expand All @@ -144,13 +147,15 @@ func TestNodeUnpublishVolume(t *testing.T) {
}
d.DiskHotPlugger = hotPlugger

targetPath := path.Join(t.TempDir(), "some-path")

_, err := d.NodeUnpublishVolume(context.Background(), &csi.NodeUnpublishVolumeRequest{
VolumeId: "volume-1",
TargetPath: "/var/lib/kubelet/some-path",
TargetPath: targetPath,
})
assert.Nil(t, err)

mounted, _ := d.DiskHotPlugger.IsMounted("/var/lib/kubelet/some-path")
mounted, _ := d.DiskHotPlugger.IsMounted(targetPath)
assert.False(t, mounted)
})
}
Expand Down

0 comments on commit b7261a3

Please sign in to comment.