0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-02 03:22:59 +00:00
terraform-provider-proxmox/proxmoxtf/utils_test.go
Kai Kahllund 82016fc8ff
frat(vm): Add custom CPU models support (#254)
* chore: add regex for custom cpu model validation

* update logic to use TF validators & add tests

---------

Co-authored-by: Kai Kahllund <kai.kahllund@akra.de>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2023-03-12 20:34:02 -04:00

38 lines
803 B
Go

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package proxmoxtf
import (
"testing"
)
func Test_getCPUTypeValidator(t *testing.T) {
t.Parallel()
tests := []struct {
name string
value string
valid bool
}{
{"empty", "", false},
{"invalid", "invalid", false},
{"valid", "host", true},
{"valid", "qemu64", true},
{"valid", "custom-abc", true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
f := getCPUTypeValidator()
res := f(tt.value, nil)
if !res.HasError() != tt.valid {
t.Errorf("validate: '%s', want %v got %v", tt.value, tt.valid, res)
}
})
}
}