terraform-provider-docker/internal/provider/data_source_docker_plugin_test.go
Manuel Vogel ad3e56da2b
feat: migrate to terraform-sdk v2 (#102)
* chore: runs v2 upgrade cmd
* chore: moves all files into the internal provider dir
* feat: migrates main and provider
* fix: migrates tests to provider factories
* fix: replace import state passthrough ctx func
* chore: bump tf-sdk to v2.4.4
* fix: acc test by adding stop grace period
* fix: move to validate diag functions
* test: switch from ctx TODO to Background
* feat: add state upgrade for restart_policy and auth

Co-authored-by: Shunsuke Suzuki <suzuki-shunsuke@users.noreply.github.com>
2021-03-18 08:30:54 +01:00

39 lines
1.1 KiB
Go

package provider
import (
"os/exec"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccDockerPluginDataSource_basic(t *testing.T) {
pluginName := "tiborvass/sample-volume-plugin"
// This fails if the plugin is already installed.
if err := exec.Command("docker", "plugin", "install", pluginName).Run(); err != nil {
t.Fatal(err)
}
defer func() {
if err := exec.Command("docker", "plugin", "rm", "-f", pluginName).Run(); err != nil {
t.Logf("failed to remove the Docker plugin %s: %v", pluginName, err)
}
}()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testAccDockerPluginDataSourceTest,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.docker_plugin.test", "plugin_reference", "docker.io/tiborvass/sample-volume-plugin:latest"),
),
},
},
})
}
const testAccDockerPluginDataSourceTest = `
data "docker_plugin" "test" {
alias = "tiborvass/sample-volume-plugin:latest"
}
`