Skip to content

Commit

Permalink
remove own ptr-func from test
Browse files Browse the repository at this point in the history
  • Loading branch information
ostempel committed Dec 13, 2024
1 parent 6197406 commit 10b3e27
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions pkg/apis/csidriverlvm/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import (

"github.com/go-logr/logr"
"github.com/stretchr/testify/assert"
"k8s.io/utils/ptr"
)

var log = logr.New(logr.Discard().GetSink())

func stringPtr(s string) *string {
return &s
}

func TestConfig(t *testing.T) {

tt := []struct {
Expand All @@ -32,71 +29,71 @@ func TestConfig(t *testing.T) {
desc: "test devicePattern nil config",
customData: &CsiDriverLvmConfig{
DevicePattern: nil,
HostWritePath: stringPtr("/etc/lvm"),
HostWritePath: ptr.To("/etc/lvm"),
},
valid: false,
},
{
desc: "test hostWritePath nil config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr("/dev/loop100"),
DevicePattern: ptr.To("/dev/loop100"),
HostWritePath: nil,
},
valid: false,
},
{
desc: "test empty config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr(""),
HostWritePath: stringPtr(""),
DevicePattern: ptr.To(""),
HostWritePath: ptr.To(""),
},
valid: false,
},
{
desc: "test empty devicePattern config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr(""),
HostWritePath: stringPtr("/etc/lvm"),
DevicePattern: ptr.To(""),
HostWritePath: ptr.To("/etc/lvm"),
},
valid: false,
},
{
desc: "test empty hostWritePath config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr("/dev/loop1"),
HostWritePath: stringPtr(""),
DevicePattern: ptr.To("/dev/loop1"),
HostWritePath: ptr.To(""),
},
valid: false,
},
{
desc: "test invalid devicePattern config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr("[a-"),
HostWritePath: stringPtr("/etc/lvm"),
DevicePattern: ptr.To("[a-"),
HostWritePath: ptr.To("/etc/lvm"),
},
valid: false,
},
{
desc: "test not absolute hostWritePath config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr("[a-z]"),
HostWritePath: stringPtr("./etc/lvm"),
DevicePattern: ptr.To("[a-z]"),
HostWritePath: ptr.To("./etc/lvm"),
},
valid: false,
},
{
desc: "test not absolute hostWritePath config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr("[a-z]"),
HostWritePath: stringPtr("etc/lvm"),
DevicePattern: ptr.To("[a-z]"),
HostWritePath: ptr.To("etc/lvm"),
},
valid: false,
},
{
desc: "test valid config",
customData: &CsiDriverLvmConfig{
DevicePattern: stringPtr("/dev/loop10[0,1]"),
HostWritePath: stringPtr("/etc/lvm"),
DevicePattern: ptr.To("/dev/loop10[0,1]"),
HostWritePath: ptr.To("/etc/lvm"),
},
valid: true,
},
Expand Down

0 comments on commit 10b3e27

Please sign in to comment.