Skip to content

Commit

Permalink
Add UT
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshaySainiDell authored Nov 12, 2024
1 parent 5d680b0 commit 24f42fd
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pkg/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,51 @@ func TestReachableEndPoint(t *testing.T) {
})
}
}

func TestGetMountFlags(t *testing.T) {
tests := []struct {
name string
vc *csi.VolumeCapability
expected []string
}{
{
name: "Nil VolumeCapability",
vc: nil,
expected: nil,
},
{
name: "Nil Mount",
vc: &csi.VolumeCapability{},
expected: nil,
},
{
name: "With Mount Flags",
vc: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{
MountFlags: []string{"ro", "noexec"},
},
},
},
expected: []string{"ro", "noexec"},
},
{
name: "Empty Mount Flags",
vc: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{
MountFlags: []string{},
},
},
},
expected: []string{},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := GetMountFlags(tt.vc)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)

Check failure on line 485 in pkg/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: GetMountFlags (typecheck)
assert.Equal(t, tt.expected, result)
})
}
}

0 comments on commit 24f42fd

Please sign in to comment.