2015-03-27 23:22:33 +01:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2015-07-03 11:58:05 +02:00
|
|
|
"testing"
|
2015-10-08 10:47:50 +02:00
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
2015-03-27 23:22:33 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAccDockerImage_basic(t *testing.T) {
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAccDockerImageConfig,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"docker_image.foo",
|
|
|
|
"latest",
|
2015-12-02 21:03:29 +01:00
|
|
|
"8dd8107abd2e22bfd3b45b05733f3d2677d4078b09b5edce56ee3d8677d3c648"),
|
2015-03-27 23:22:33 +01:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-07-03 11:58:05 +02:00
|
|
|
func TestAddDockerImage_private(t *testing.T) {
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
resource.TestStep{
|
|
|
|
Config: testAddDockerPrivateImageConfig,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"docker_image.foobar",
|
|
|
|
"latest",
|
|
|
|
"2c40b0526b6358710fd09e7b8c022429268cc61703b4777e528ac9d469a07ca1"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-03-27 23:22:33 +01:00
|
|
|
const testAccDockerImageConfig = `
|
|
|
|
resource "docker_image" "foo" {
|
2015-12-02 21:03:29 +01:00
|
|
|
name = "alpine:3.1"
|
|
|
|
keep_updated = false
|
2015-03-27 23:22:33 +01:00
|
|
|
}
|
|
|
|
`
|
2015-07-03 11:58:05 +02:00
|
|
|
|
|
|
|
const testAddDockerPrivateImageConfig = `
|
|
|
|
resource "docker_image" "foobar" {
|
|
|
|
name = "gcr.io:443/google_containers/pause:0.8.0"
|
|
|
|
keep_updated = true
|
|
|
|
}
|
|
|
|
`
|