Skip to content
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: 2 additions & 2 deletions cmd/minikube/cmd/config/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ func IsValidDiskSize(_, disksize string) error {

// IsValidCPUs checks if a string is a valid number of CPUs
func IsValidCPUs(name, cpus string) error {
if cpus == constants.MaxResources {
if cpus == constants.MaxResources || cpus == constants.NoLimit {
return nil
}
return IsPositive(name, cpus)
}

// IsValidMemory checks if a string is a valid memory size
func IsValidMemory(_, memsize string) error {
if memsize == constants.MaxResources {
if memsize == constants.MaxResources || memsize == constants.NoLimit {
return nil
}
_, err := units.FromHumanSize(memsize)
Expand Down
28 changes: 28 additions & 0 deletions cmd/minikube/cmd/config/validations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,31 @@ func TestIsURLExists(t *testing.T) {

runValidations(t, tests, "url", IsURLExists)
}

func TestIsValidCPUs(t *testing.T) {
tests := []validationTest{
{"2", false},
{"16", false},
{"max", false},
{"no-limit", false},
{"abc", true},
{"-2", true},
{"", true},
}

runValidations(t, tests, "cpus", IsValidCPUs)
}

func TestIsValidMemory(t *testing.T) {
tests := []validationTest{
{"4000mb", false},
{"8gb", false},
{"max", false},
{"no-limit", false},
{"-4000", true},
{"abc", true},
{"", true},
}

runValidations(t, tests, "memory", IsValidMemory)
}