mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 18:42:58 +00:00
* feat: add support for "args" flag for VM * switch from args to kvmarguments, update type * cosmetics: `kvmarguments` -> `kvm_arguments` also update doc to match description from the official PVE documentation. * fix(vm): Add parser for CustomEFIDisk * use parseDiskSize(&string) from utils.go for CustomEFIDisk * readd the remove space by github space * address linter errors, remove duplicated code, add unit test Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
38 lines
852 B
Go
38 lines
852 B
Go
package proxmox
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestParseDiskSize(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
size *string
|
|
want int
|
|
wantErr bool
|
|
}{
|
|
{"handle null size", nil, 0, false},
|
|
{"parse terabytes", strPtr("2T"), 2048, false},
|
|
{"parse gigabytes", strPtr("2G"), 2, false},
|
|
{"parse megabytes", strPtr("2048M"), 2, false},
|
|
{"error on arbitrary string", strPtr("something"), -1, true},
|
|
{"error on missing unit", strPtr("12345"), -1, true},
|
|
}
|
|
for _, test := range tests {
|
|
tt := test
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
got, err := ParseDiskSize(tt.size)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("ParseDiskSize() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
if got != tt.want {
|
|
t.Errorf("ParseDiskSize() got = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|