2021-03-18 03:30:54 -04:00
|
|
|
package provider
|
2021-01-08 10:38:30 -05:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os/exec"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2021-03-18 03:30:54 -04:00
|
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
2021-01-08 10:38:30 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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{
|
2021-03-18 03:30:54 -04:00
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
ProviderFactories: providerFactories,
|
2021-01-08 10:38:30 -05:00
|
|
|
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"
|
|
|
|
|
}
|
|
|
|
|
`
|