providers/google: tests passing, compiling
This commit is contained in:
parent
55f4e35586
commit
ecc10616ba
|
@ -31,13 +31,13 @@ func TestAccComputeAddress_basic(t *testing.T) {
|
||||||
func testAccCheckComputeAddressDestroy(s *terraform.State) error {
|
func testAccCheckComputeAddressDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "google_compute_address" {
|
if rs.Type != "google_compute_address" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := config.clientCompute.Addresses.Get(
|
_, err := config.clientCompute.Addresses.Get(
|
||||||
config.Project, config.Region, rs.ID).Do()
|
config.Project, config.Region, rs.Primary.ID).Do()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Address still exists")
|
return fmt.Errorf("Address still exists")
|
||||||
}
|
}
|
||||||
|
@ -48,24 +48,24 @@ func testAccCheckComputeAddressDestroy(s *terraform.State) error {
|
||||||
|
|
||||||
func testAccCheckComputeAddressExists(n string, addr *compute.Address) resource.TestCheckFunc {
|
func testAccCheckComputeAddressExists(n string, addr *compute.Address) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not found: %s", n)
|
return fmt.Errorf("Not found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
found, err := config.clientCompute.Addresses.Get(
|
found, err := config.clientCompute.Addresses.Get(
|
||||||
config.Project, config.Region, rs.ID).Do()
|
config.Project, config.Region, rs.Primary.ID).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if found.Name != rs.ID {
|
if found.Name != rs.Primary.ID {
|
||||||
return fmt.Errorf("Addr not found")
|
return fmt.Errorf("Addr not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,13 @@ func TestAccComputeDisk_basic(t *testing.T) {
|
||||||
func testAccCheckComputeDiskDestroy(s *terraform.State) error {
|
func testAccCheckComputeDiskDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "google_compute_disk" {
|
if rs.Type != "google_compute_disk" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := config.clientCompute.Disks.Get(
|
_, err := config.clientCompute.Disks.Get(
|
||||||
config.Project, rs.Attributes["zone"], rs.ID).Do()
|
config.Project, rs.Primary.Attributes["zone"], rs.Primary.ID).Do()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Disk still exists")
|
return fmt.Errorf("Disk still exists")
|
||||||
}
|
}
|
||||||
|
@ -48,24 +48,24 @@ func testAccCheckComputeDiskDestroy(s *terraform.State) error {
|
||||||
|
|
||||||
func testAccCheckComputeDiskExists(n string, disk *compute.Disk) resource.TestCheckFunc {
|
func testAccCheckComputeDiskExists(n string, disk *compute.Disk) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not found: %s", n)
|
return fmt.Errorf("Not found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
found, err := config.clientCompute.Disks.Get(
|
found, err := config.clientCompute.Disks.Get(
|
||||||
config.Project, rs.Attributes["zone"], rs.ID).Do()
|
config.Project, rs.Primary.Attributes["zone"], rs.Primary.ID).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if found.Name != rs.ID {
|
if found.Name != rs.Primary.ID {
|
||||||
return fmt.Errorf("Disk not found")
|
return fmt.Errorf("Disk not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,13 +59,13 @@ func TestAccComputeFirewall_update(t *testing.T) {
|
||||||
func testAccCheckComputeFirewallDestroy(s *terraform.State) error {
|
func testAccCheckComputeFirewallDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "google_compute_firewall" {
|
if rs.Type != "google_compute_firewall" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := config.clientCompute.Firewalls.Get(
|
_, err := config.clientCompute.Firewalls.Get(
|
||||||
config.Project, rs.ID).Do()
|
config.Project, rs.Primary.ID).Do()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Firewall still exists")
|
return fmt.Errorf("Firewall still exists")
|
||||||
}
|
}
|
||||||
|
@ -76,24 +76,24 @@ func testAccCheckComputeFirewallDestroy(s *terraform.State) error {
|
||||||
|
|
||||||
func testAccCheckComputeFirewallExists(n string, firewall *compute.Firewall) resource.TestCheckFunc {
|
func testAccCheckComputeFirewallExists(n string, firewall *compute.Firewall) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not found: %s", n)
|
return fmt.Errorf("Not found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
found, err := config.clientCompute.Firewalls.Get(
|
found, err := config.clientCompute.Firewalls.Get(
|
||||||
config.Project, rs.ID).Do()
|
config.Project, rs.Primary.ID).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if found.Name != rs.ID {
|
if found.Name != rs.Primary.ID {
|
||||||
return fmt.Errorf("Firewall not found")
|
return fmt.Errorf("Firewall not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,13 +106,13 @@ func TestAccComputeInstance_update(t *testing.T) {
|
||||||
func testAccCheckComputeInstanceDestroy(s *terraform.State) error {
|
func testAccCheckComputeInstanceDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "google_compute_instance" {
|
if rs.Type != "google_compute_instance" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := config.clientCompute.Instances.Get(
|
_, err := config.clientCompute.Instances.Get(
|
||||||
config.Project, rs.Attributes["zone"], rs.ID).Do()
|
config.Project, rs.Primary.Attributes["zone"], rs.Primary.ID).Do()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Instance still exists")
|
return fmt.Errorf("Instance still exists")
|
||||||
}
|
}
|
||||||
|
@ -123,24 +123,24 @@ func testAccCheckComputeInstanceDestroy(s *terraform.State) error {
|
||||||
|
|
||||||
func testAccCheckComputeInstanceExists(n string, instance *compute.Instance) resource.TestCheckFunc {
|
func testAccCheckComputeInstanceExists(n string, instance *compute.Instance) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not found: %s", n)
|
return fmt.Errorf("Not found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
found, err := config.clientCompute.Instances.Get(
|
found, err := config.clientCompute.Instances.Get(
|
||||||
config.Project, rs.Attributes["zone"], rs.ID).Do()
|
config.Project, rs.Primary.Attributes["zone"], rs.Primary.ID).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if found.Name != rs.ID {
|
if found.Name != rs.Primary.ID {
|
||||||
return fmt.Errorf("Instance not found")
|
return fmt.Errorf("Instance not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,13 @@ func TestAccComputeNetwork_basic(t *testing.T) {
|
||||||
func testAccCheckComputeNetworkDestroy(s *terraform.State) error {
|
func testAccCheckComputeNetworkDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "google_compute_network" {
|
if rs.Type != "google_compute_network" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := config.clientCompute.Networks.Get(
|
_, err := config.clientCompute.Networks.Get(
|
||||||
config.Project, rs.ID).Do()
|
config.Project, rs.Primary.ID).Do()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Network still exists")
|
return fmt.Errorf("Network still exists")
|
||||||
}
|
}
|
||||||
|
@ -48,24 +48,24 @@ func testAccCheckComputeNetworkDestroy(s *terraform.State) error {
|
||||||
|
|
||||||
func testAccCheckComputeNetworkExists(n string, network *compute.Network) resource.TestCheckFunc {
|
func testAccCheckComputeNetworkExists(n string, network *compute.Network) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not found: %s", n)
|
return fmt.Errorf("Not found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
found, err := config.clientCompute.Networks.Get(
|
found, err := config.clientCompute.Networks.Get(
|
||||||
config.Project, rs.ID).Do()
|
config.Project, rs.Primary.ID).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if found.Name != rs.ID {
|
if found.Name != rs.Primary.ID {
|
||||||
return fmt.Errorf("Network not found")
|
return fmt.Errorf("Network not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,13 @@ func TestAccComputeRoute_basic(t *testing.T) {
|
||||||
func testAccCheckComputeRouteDestroy(s *terraform.State) error {
|
func testAccCheckComputeRouteDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
if rs.Type != "google_compute_route" {
|
if rs.Type != "google_compute_route" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := config.clientCompute.Routes.Get(
|
_, err := config.clientCompute.Routes.Get(
|
||||||
config.Project, rs.ID).Do()
|
config.Project, rs.Primary.ID).Do()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Route still exists")
|
return fmt.Errorf("Route still exists")
|
||||||
}
|
}
|
||||||
|
@ -48,24 +48,24 @@ func testAccCheckComputeRouteDestroy(s *terraform.State) error {
|
||||||
|
|
||||||
func testAccCheckComputeRouteExists(n string, route *compute.Route) resource.TestCheckFunc {
|
func testAccCheckComputeRouteExists(n string, route *compute.Route) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Not found: %s", n)
|
return fmt.Errorf("Not found: %s", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rs.ID == "" {
|
if rs.Primary.ID == "" {
|
||||||
return fmt.Errorf("No ID is set")
|
return fmt.Errorf("No ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
found, err := config.clientCompute.Routes.Get(
|
found, err := config.clientCompute.Routes.Get(
|
||||||
config.Project, rs.ID).Do()
|
config.Project, rs.Primary.ID).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if found.Name != rs.ID {
|
if found.Name != rs.Primary.ID {
|
||||||
return fmt.Errorf("Route not found")
|
return fmt.Errorf("Route not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue