0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-08-22 11:28:33 +00:00
terraform-provider-proxmox/proxmoxtf/datasource/containers_test.go
k69420s 45f28051cd
feat(lxc): add proxmox_virtual_environment_containers data source (#2090)
* feat(lxc): add `proxmox_virtual_environment_containers` data source

- Implements a new data source for fetching container details in Proxmox environments.
- Includes support for filtering by attributes such as name, template, status, and tags.
- Provides documentation and test coverage for the new functionality.

Signed-off-by: k69420s <k69420s@localhost.localdomain>

* suppress duplication error in linter, fix example code

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

---------

Signed-off-by: k69420s <k69420s@localhost.localdomain>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2025-08-14 18:26:47 -04:00

66 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 datasource
import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/test"
)
// TestContainersInstantiation tests whether the dataSourceVirtualEnvironmentContainers instance can be instantiated.
func TestContainersInstantiation(t *testing.T) {
t.Parallel()
s := Containers()
if s == nil {
t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentContainers")
}
}
// TestContainersSchema tests the dataSourceVirtualEnvironmentContainers schema.
func TestContainersSchema(t *testing.T) {
t.Parallel()
s := Containers().Schema
test.AssertComputedAttributes(t, s, []string{
mkDataSourceVirtualEnvironmentContainers,
})
test.AssertValueTypes(t, s, map[string]schema.ValueType{
mkDataSourceVirtualEnvironmentContainerNodeName: schema.TypeString,
mkDataSourceVirtualEnvironmentContainerTags: schema.TypeList,
mkDataSourceFilter: schema.TypeList,
mkDataSourceVirtualEnvironmentContainers: schema.TypeList,
})
containersSchema := test.AssertNestedSchemaExistence(t, s, mkDataSourceVirtualEnvironmentContainers)
test.AssertComputedAttributes(t, containersSchema, []string{
mkDataSourceVirtualEnvironmentContainerName,
mkDataSourceVirtualEnvironmentContainerTags,
})
test.AssertValueTypes(t, containersSchema, map[string]schema.ValueType{
mkDataSourceVirtualEnvironmentContainerName: schema.TypeString,
mkDataSourceVirtualEnvironmentContainerNodeName: schema.TypeString,
mkDataSourceVirtualEnvironmentContainerTags: schema.TypeList,
mkDataSourceVirtualEnvironmentContainerVMID: schema.TypeInt,
})
filterSchema := test.AssertNestedSchemaExistence(t, s, mkDataSourceFilter)
test.AssertValueTypes(t, filterSchema, map[string]schema.ValueType{
mkDataSourceFilterName: schema.TypeString,
mkDataSourceFilterValues: schema.TypeList,
mkDataSourceFilterRegex: schema.TypeBool,
})
}