0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-04 04:22:59 +00:00
terraform-provider-proxmox/internal/test/datasource_version_test.go
Pavel Boldyrev a9a7329d9f
feat(core): migrate version datasource to TF plugin framework (#440)
* feat: migrate `version` datasource to tf framework

* set up documentation generator

* add generated docs for network resources

* fix test mux server, add import examples to network resources

* fix network tests

* fix shell examples
2023-07-29 02:10:02 +00:00

46 lines
1.2 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 test
import (
"context"
"fmt"
"strings"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func Test_VersionDatasource(t *testing.T) {
t.Parallel()
accProviders := AccMuxProviders(context.Background(), t)
datasourceName := "data.proxmox_virtual_environment_version.test"
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: accProviders,
Steps: []resource.TestStep{
// Read testing
{
Config: ProviderConfig + `data "proxmox_virtual_environment_version" "test" {}`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(datasourceName, "release", "8.0"),
resource.TestCheckResourceAttrSet(datasourceName, "repository_id"),
resource.TestCheckResourceAttrWith(datasourceName, "version", func(value string) error {
if strings.HasPrefix(value, "8.0") {
return nil
}
return fmt.Errorf("version %s does not start with 8.0", value)
}),
resource.TestCheckResourceAttrSet(datasourceName, "id"),
),
},
},
})
}