0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 11:02:59 +00:00
terraform-provider-proxmox/proxmoxtf/provider/provider_test.go
Oto Petřík 926382c155
fix(core): Do not limit cluster size to 1 in provider's ssh config (#369)
fix(code): Do not limit cluster size to 1

Allow using repeated 'node' blocks in ssh configuration.

Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2023-06-07 23:06:10 +00:00

78 lines
2.1 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 provider
import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/test"
)
// TestProviderInstantiation() tests whether the ProxmoxVirtualEnvironment instance can be instantiated.
func TestProviderInstantiation(t *testing.T) {
t.Parallel()
s := ProxmoxVirtualEnvironment()
if s == nil {
t.Fatalf("Cannot instantiate ProxmoxVirtualEnvironment")
}
}
// TestProviderSchema() tests the ProxmoxVirtualEnvironment schema.
func TestProviderSchema(t *testing.T) {
t.Parallel()
s := &schema.Resource{
Schema: ProxmoxVirtualEnvironment().Schema,
}
test.AssertOptionalArguments(t, s, []string{
mkProviderVirtualEnvironment,
mkProviderUsername,
mkProviderPassword,
mkProviderEndpoint,
mkProviderInsecure,
mkProviderOTP,
})
test.AssertValueTypes(t, s, map[string]schema.ValueType{
mkProviderVirtualEnvironment: schema.TypeList,
mkProviderUsername: schema.TypeString,
mkProviderPassword: schema.TypeString,
mkProviderEndpoint: schema.TypeString,
mkProviderInsecure: schema.TypeBool,
mkProviderOTP: schema.TypeString,
})
veSchema := test.AssertNestedSchemaExistence(t, s, mkProviderVirtualEnvironment)
test.AssertOptionalArguments(t, veSchema, []string{
mkProviderEndpoint,
mkProviderInsecure,
mkProviderOTP,
mkProviderPassword,
mkProviderUsername,
mkProviderSSH,
})
test.AssertValueTypes(t, veSchema, map[string]schema.ValueType{
mkProviderEndpoint: schema.TypeString,
mkProviderInsecure: schema.TypeBool,
mkProviderOTP: schema.TypeString,
mkProviderPassword: schema.TypeString,
mkProviderUsername: schema.TypeString,
mkProviderSSH: schema.TypeList,
})
providerSSHSchema := test.AssertNestedSchemaExistence(t, s, mkProviderSSH)
// do not limit number of nodes in the cluster
test.AssertListMaxItems(t, providerSSHSchema, mkProviderSSHNode, 0)
}