0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-02 03:22:59 +00:00
terraform-provider-proxmox/utils/maps_test.go
Serge dbbd966736
feat(vm): add support for numa architecture attribute (#1156) (#1175)
* feat(vm): add support for numa architecture attribute (#1156)

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>

* fix: numa blocks reordering issue

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>

---------

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2024-04-06 16:30:13 -04:00

50 lines
1.2 KiB
Go

package utils
import (
"reflect"
"testing"
)
func TestMapResourceList(t *testing.T) {
t.Parallel()
resourceList := []interface{}{
map[string]interface{}{"name": "resource1", "attr": "value1"},
map[string]interface{}{"name": "resource2", "attr": "value2"},
map[string]interface{}{"name": "resource3", "attr": "value3"},
}
expected := map[string]interface{}{
"value1": map[string]interface{}{"name": "resource1", "attr": "value1"},
"value2": map[string]interface{}{"name": "resource2", "attr": "value2"},
"value3": map[string]interface{}{"name": "resource3", "attr": "value3"},
}
result := MapResourceList(resourceList, "attr")
if !reflect.DeepEqual(result, expected) {
t.Errorf("MapResourceList() = %v, want %v", result, expected)
}
}
func TestOrderedListFromMapByKeyValues(t *testing.T) {
t.Parallel()
inputMap := map[string]interface{}{
"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4",
}
keyList := []string{"key2", "key1", "key4"}
expected := []interface{}{"value2", "value1", "value4"}
result := OrderedListFromMapByKeyValues(inputMap, keyList)
if !reflect.DeepEqual(result, expected) {
t.Errorf("OrderedListFromMapByKeyValues() = %v, want %v", result, expected)
}
}