Skip to content

Commit

Permalink
go fmt after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed May 17, 2016
1 parent 9f707e3 commit bc71d70
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 70 deletions.
22 changes: 11 additions & 11 deletions builtin/providers/fastly/resource_fastly_service_v1.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fastly

import (
"crypto/sha1"
"encoding/hex"
"crypto/sha1"
"encoding/hex"
"errors"
"fmt"
"log"
Expand Down Expand Up @@ -485,15 +485,15 @@ func resourceServiceV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
Description: "The contents of this VCL configuration",
StateFunc: func(v interface{}) string {
switch v.(type) {
case string:
hash := sha1.Sum([]byte(v.(string)))
return hex.EncodeToString(hash[:])
default:
return ""
}
},
StateFunc: func(v interface{}) string {
switch v.(type) {
case string:
hash := sha1.Sum([]byte(v.(string)))
return hex.EncodeToString(hash[:])
default:
return ""
}
},
},
"main": &schema.Schema{
Type: schema.TypeBool,
Expand Down
118 changes: 59 additions & 59 deletions builtin/providers/fastly/resource_fastly_service_v1_vcl_test.go
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
package fastly

import (
"fmt"
"testing"
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
gofastly "github.com/sethvargo/go-fastly"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
gofastly "github.com/sethvargo/go-fastly"
)

func TestAccFastlyServiceV1_VCL_basic(t *testing.T) {
var service gofastly.ServiceDetail
name := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckServiceV1Destroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccServiceV1VCLConfig(name, domainName1),
Check: resource.ComposeTestCheckFunc(
testAccCheckServiceV1Exists("fastly_service_v1.foo", &service),
testAccCheckFastlyServiceV1VCLAttributes(&service, name, 1),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "name", name),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "vcl.#", "1"),
),
},

resource.TestStep{
Config: testAccServiceV1VCLConfig_update(name, domainName1),
Check: resource.ComposeTestCheckFunc(
testAccCheckServiceV1Exists("fastly_service_v1.foo", &service),
testAccCheckFastlyServiceV1VCLAttributes(&service, name, 2),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "name", name),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "vcl.#", "2"),
),
},
},
})
var service gofastly.ServiceDetail
name := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
domainName1 := fmt.Sprintf("%s.notadomain.com", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckServiceV1Destroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccServiceV1VCLConfig(name, domainName1),
Check: resource.ComposeTestCheckFunc(
testAccCheckServiceV1Exists("fastly_service_v1.foo", &service),
testAccCheckFastlyServiceV1VCLAttributes(&service, name, 1),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "name", name),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "vcl.#", "1"),
),
},

resource.TestStep{
Config: testAccServiceV1VCLConfig_update(name, domainName1),
Check: resource.ComposeTestCheckFunc(
testAccCheckServiceV1Exists("fastly_service_v1.foo", &service),
testAccCheckFastlyServiceV1VCLAttributes(&service, name, 2),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "name", name),
resource.TestCheckResourceAttr(
"fastly_service_v1.foo", "vcl.#", "2"),
),
},
},
})
}

func testAccCheckFastlyServiceV1VCLAttributes(service *gofastly.ServiceDetail, name string, vclCount int) resource.TestCheckFunc {
return func(s *terraform.State) error {
return func(s *terraform.State) error {

if service.Name != name {
return fmt.Errorf("Bad name, expected (%s), got (%s)", name, service.Name)
}
if service.Name != name {
return fmt.Errorf("Bad name, expected (%s), got (%s)", name, service.Name)
}

conn := testAccProvider.Meta().(*FastlyClient).conn
vclList, err := conn.ListVCLs(&gofastly.ListVCLsInput{
Service: service.ID,
Version: service.ActiveVersion.Number,
})
conn := testAccProvider.Meta().(*FastlyClient).conn
vclList, err := conn.ListVCLs(&gofastly.ListVCLsInput{
Service: service.ID,
Version: service.ActiveVersion.Number,
})

if err != nil {
return fmt.Errorf("[ERR] Error looking up VCL for (%s), version (%s): %s", service.Name, service.ActiveVersion.Number, err)
}
if err != nil {
return fmt.Errorf("[ERR] Error looking up VCL for (%s), version (%s): %s", service.Name, service.ActiveVersion.Number, err)
}

if len(vclList) != vclCount {
return fmt.Errorf("VCL count mismatch, expected (%d), got (%d)", vclCount, len(vclList))
}
if len(vclList) != vclCount {
return fmt.Errorf("VCL count mismatch, expected (%d), got (%d)", vclCount, len(vclList))
}

return nil
}
return nil
}
}

func testAccServiceV1VCLConfig(name, domain string) string {
return fmt.Sprintf(`
return fmt.Sprintf(`
resource "fastly_service_v1" "foo" {
name = "%s"
Expand Down Expand Up @@ -108,7 +108,7 @@ EOF
}

func testAccServiceV1VCLConfig_update(name, domain string) string {
return fmt.Sprintf(`
return fmt.Sprintf(`
resource "fastly_service_v1" "foo" {
name = "%s"
Expand Down

0 comments on commit bc71d70

Please sign in to comment.