mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
chore(vm): refactoring: extract network code Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
78 lines
2.4 KiB
Go
78 lines
2.4 KiB
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 resource
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
|
|
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/test"
|
|
)
|
|
|
|
// TestHostsInstantiation tests whether the Hosts instance can be instantiated.
|
|
func TestHostsInstantiation(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
s := Hosts()
|
|
if s == nil {
|
|
t.Fatalf("Cannot instantiate Hosts")
|
|
}
|
|
}
|
|
|
|
// TestHostsSchema tests the Hosts schema.
|
|
func TestHostsSchema(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
s := Hosts().Schema
|
|
|
|
test.AssertRequiredArguments(t, s, []string{
|
|
mkResourceVirtualEnvironmentHostsEntry,
|
|
mkResourceVirtualEnvironmentHostsNodeName,
|
|
})
|
|
|
|
test.AssertComputedAttributes(t, s, []string{
|
|
mkResourceVirtualEnvironmentHostsAddresses,
|
|
mkResourceVirtualEnvironmentHostsDigest,
|
|
mkResourceVirtualEnvironmentHostsEntries,
|
|
mkResourceVirtualEnvironmentHostsHostnames,
|
|
})
|
|
|
|
test.AssertValueTypes(t, s, map[string]schema.ValueType{
|
|
mkResourceVirtualEnvironmentHostsAddresses: schema.TypeList,
|
|
mkResourceVirtualEnvironmentHostsDigest: schema.TypeString,
|
|
mkResourceVirtualEnvironmentHostsEntries: schema.TypeList,
|
|
mkResourceVirtualEnvironmentHostsEntry: schema.TypeList,
|
|
mkResourceVirtualEnvironmentHostsHostnames: schema.TypeList,
|
|
mkResourceVirtualEnvironmentHostsNodeName: schema.TypeString,
|
|
})
|
|
|
|
entriesSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentHostsEntries)
|
|
|
|
test.AssertComputedAttributes(t, entriesSchema, []string{
|
|
mkResourceVirtualEnvironmentHostsEntriesAddress,
|
|
mkResourceVirtualEnvironmentHostsEntriesHostnames,
|
|
})
|
|
|
|
test.AssertValueTypes(t, entriesSchema, map[string]schema.ValueType{
|
|
mkResourceVirtualEnvironmentHostsEntriesAddress: schema.TypeString,
|
|
mkResourceVirtualEnvironmentHostsEntriesHostnames: schema.TypeList,
|
|
})
|
|
|
|
entrySchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentHostsEntry)
|
|
|
|
test.AssertRequiredArguments(t, entrySchema, []string{
|
|
mkResourceVirtualEnvironmentHostsEntryAddress,
|
|
mkResourceVirtualEnvironmentHostsEntryHostnames,
|
|
})
|
|
|
|
test.AssertValueTypes(t, entrySchema, map[string]schema.ValueType{
|
|
mkResourceVirtualEnvironmentHostsEntryAddress: schema.TypeString,
|
|
mkResourceVirtualEnvironmentHostsEntryHostnames: schema.TypeList,
|
|
})
|
|
}
|