Skip to content

Commit

Permalink
Merge pull request #22 from nvthongswansea/docs
Browse files Browse the repository at this point in the history
Update docs and coding convention
  • Loading branch information
itakouna authored Oct 24, 2019
2 parents 2d7903e + 48814d5 commit c30e3ac
Show file tree
Hide file tree
Showing 20 changed files with 241 additions and 95 deletions.
2 changes: 1 addition & 1 deletion gridscale/datasource_gridscale_ipv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestAccdataSourceGridscaleIPv4_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleIpv4DestroyCheck,
CheckDestroy: testAccCheckGridscaleIpv4DestroyCheck,
Steps: []resource.TestStep{
{

Expand Down
2 changes: 1 addition & 1 deletion gridscale/datasource_gridscale_ipv6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestAccdataSourceGridscaleIPv6_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleIpv6DestroyCheck,
CheckDestroy: testAccCheckGridscaleIpv6DestroyCheck,
Steps: []resource.TestStep{
{

Expand Down
2 changes: 1 addition & 1 deletion gridscale/datasource_gridscale_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestAccdataSourceGridscaleLoadBalancer_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckResourceGridscaleLoadBalancerDestroyCheck,
CheckDestroy: testAccCheckGridscaleLoadBalancerDestroyCheck,
Steps: []resource.TestStep{
{

Expand Down
2 changes: 1 addition & 1 deletion gridscale/datasource_gridscale_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestAccdataSourceGridscaleNetwork_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleNetworkDestroyCheck,
CheckDestroy: testAccCheckGridscaleNetworkDestroyCheck,
Steps: []resource.TestStep{
{

Expand Down
2 changes: 1 addition & 1 deletion gridscale/datasource_gridscale_sshkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestAccdataSourceGridscaleSSHKey_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleSshkeyDestroyCheck,
CheckDestroy: testAccCheckGridscaleSshkeyDestroyCheck,
Steps: []resource.TestStep{
{

Expand Down
2 changes: 1 addition & 1 deletion gridscale/datasource_gridscale_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestAccdataSourceGridscaleStorage_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleStorageDestroyCheck,
CheckDestroy: testAccCheckGridscaleStorageDestroyCheck,
Steps: []resource.TestStep{
{

Expand Down
20 changes: 10 additions & 10 deletions gridscale/resource_gridscale_ipv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ import (
"github.com/gridscale/gsclient-go"
)

func TestAccDataSourceGridscaleIpv4_Basic(t *testing.T) {
func TestAccResourceGridscaleIpv4_Basic(t *testing.T) {
var object gsclient.IP
name := fmt.Sprintf("object-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleIpv4DestroyCheck,
CheckDestroy: testAccCheckGridscaleIpv4DestroyCheck,
Steps: []resource.TestStep{
{
Config: testAccCheckDataSourceGridscaleIpv4Config_basic(name),
Config: testAccCheckResourceGridscaleIpv4Config_basic(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleIpv4Exists("gridscale_ipv4.foo", &object),
testAccCheckResourceGridscaleIpv4Exists("gridscale_ipv4.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_ipv4.foo", "name", name),
),
},
{
Config: testAccCheckDataSourceGridscaleIpv4Config_basic_update(),
Config: testAccCheckResourceGridscaleIpv4Config_basic_update(),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleIpv4Exists("gridscale_ipv4.foo", &object),
testAccCheckResourceGridscaleIpv4Exists("gridscale_ipv4.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_ipv4.foo", "name", "newname"),
resource.TestCheckResourceAttr(
Expand All @@ -44,7 +44,7 @@ func TestAccDataSourceGridscaleIpv4_Basic(t *testing.T) {
})
}

func testAccCheckDataSourceGridscaleIpv4Exists(n string, object *gsclient.IP) resource.TestCheckFunc {
func testAccCheckResourceGridscaleIpv4Exists(n string, object *gsclient.IP) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]

Expand Down Expand Up @@ -76,7 +76,7 @@ func testAccCheckDataSourceGridscaleIpv4Exists(n string, object *gsclient.IP) re
}
}

func testAccCheckDataSourceGridscaleIpv4DestroyCheck(s *terraform.State) error {
func testAccCheckGridscaleIpv4DestroyCheck(s *terraform.State) error {
client := testAccProvider.Meta().(*gsclient.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "gridscale_ipv4" {
Expand All @@ -100,15 +100,15 @@ func testAccCheckDataSourceGridscaleIpv4DestroyCheck(s *terraform.State) error {
return nil
}

func testAccCheckDataSourceGridscaleIpv4Config_basic(name string) string {
func testAccCheckResourceGridscaleIpv4Config_basic(name string) string {
return fmt.Sprintf(`
resource "gridscale_ipv4" "foo" {
name = "%s"
}
`, name)
}

func testAccCheckDataSourceGridscaleIpv4Config_basic_update() string {
func testAccCheckResourceGridscaleIpv4Config_basic_update() string {
return fmt.Sprintf(`
resource "gridscale_ipv4" "foo" {
name = "newname"
Expand Down
20 changes: 10 additions & 10 deletions gridscale/resource_gridscale_ipv6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ import (
"github.com/gridscale/gsclient-go"
)

func TestAccDataSourceGridscaleIpv6_Basic(t *testing.T) {
func TestAccResourceGridscaleIpv6_Basic(t *testing.T) {
var object gsclient.IP
name := fmt.Sprintf("object-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleIpv6DestroyCheck,
CheckDestroy: testAccCheckGridscaleIpv6DestroyCheck,
Steps: []resource.TestStep{
{
Config: testAccCheckDataSourceGridscaleIpv6Config_basic(name),
Config: testAccCheckResourceGridscaleIpv6Config_basic(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleIpv6Exists("gridscale_ipv6.foo", &object),
testAccCheckResourceGridscaleIpv6Exists("gridscale_ipv6.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_ipv6.foo", "name", name),
),
},
{
Config: testAccCheckDataSourceGridscaleIpv6Config_basic_update(),
Config: testAccCheckResourceGridscaleIpv6Config_basic_update(),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleIpv6Exists("gridscale_ipv6.foo", &object),
testAccCheckResourceGridscaleIpv6Exists("gridscale_ipv6.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_ipv6.foo", "name", "newname"),
resource.TestCheckResourceAttr(
Expand All @@ -44,7 +44,7 @@ func TestAccDataSourceGridscaleIpv6_Basic(t *testing.T) {
})
}

func testAccCheckDataSourceGridscaleIpv6Exists(n string, object *gsclient.IP) resource.TestCheckFunc {
func testAccCheckResourceGridscaleIpv6Exists(n string, object *gsclient.IP) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]

Expand Down Expand Up @@ -76,7 +76,7 @@ func testAccCheckDataSourceGridscaleIpv6Exists(n string, object *gsclient.IP) re
}
}

func testAccCheckDataSourceGridscaleIpv6DestroyCheck(s *terraform.State) error {
func testAccCheckGridscaleIpv6DestroyCheck(s *terraform.State) error {
client := testAccProvider.Meta().(*gsclient.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "gridscale_ipv6" {
Expand All @@ -100,15 +100,15 @@ func testAccCheckDataSourceGridscaleIpv6DestroyCheck(s *terraform.State) error {
return nil
}

func testAccCheckDataSourceGridscaleIpv6Config_basic(name string) string {
func testAccCheckResourceGridscaleIpv6Config_basic(name string) string {
return fmt.Sprintf(`
resource "gridscale_ipv6" "foo" {
name = "%s"
}
`, name)
}

func testAccCheckDataSourceGridscaleIpv6Config_basic_update() string {
func testAccCheckResourceGridscaleIpv6Config_basic_update() string {
return fmt.Sprintf(`
resource "gridscale_ipv6" "foo" {
name = "newname"
Expand Down
4 changes: 2 additions & 2 deletions gridscale/resource_gridscale_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccResourceGridscaleLoadBalancerBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckResourceGridscaleLoadBalancerDestroyCheck,
CheckDestroy: testAccCheckGridscaleLoadBalancerDestroyCheck,
Steps: []resource.TestStep{
{
Config: testAccCheckResourceGridscaleLoadBalancerConfig_basic(name, "leastconn"),
Expand Down Expand Up @@ -136,7 +136,7 @@ resource "gridscale_loadbalancer" "foo" {
}`, name, name, name, name, algorithm)
}

func testAccCheckResourceGridscaleLoadBalancerDestroyCheck(s *terraform.State) error {
func testAccCheckGridscaleLoadBalancerDestroyCheck(s *terraform.State) error {
client := testAccProvider.Meta().(*gsclient.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "gridscale_loadbalancer" {
Expand Down
20 changes: 10 additions & 10 deletions gridscale/resource_gridscale_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ import (
"github.com/gridscale/gsclient-go"
)

func TestAccDataSourceGridscaleNetwork_Basic(t *testing.T) {
func TestAccResourceGridscaleNetwork_Basic(t *testing.T) {
var object gsclient.Network
name := fmt.Sprintf("object-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleNetworkDestroyCheck,
CheckDestroy: testAccCheckGridscaleNetworkDestroyCheck,
Steps: []resource.TestStep{
{
Config: testAccCheckDataSourceGridscaleNetworkConfig_basic(name),
Config: testAccCheckResourceGridscaleNetworkConfig_basic(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleNetworkExists("gridscale_network.foo", &object),
testAccCheckResourceGridscaleNetworkExists("gridscale_network.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_network.foo", "name", name),
),
},
{
Config: testAccCheckDataSourceGridscaleNetworkConfig_basic_update(),
Config: testAccCheckResourceGridscaleNetworkConfig_basic_update(),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleNetworkExists("gridscale_network.foo", &object),
testAccCheckResourceGridscaleNetworkExists("gridscale_network.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_network.foo", "name", "newname"),
resource.TestCheckResourceAttr(
Expand All @@ -42,7 +42,7 @@ func TestAccDataSourceGridscaleNetwork_Basic(t *testing.T) {
})
}

func testAccCheckDataSourceGridscaleNetworkExists(n string, object *gsclient.Network) resource.TestCheckFunc {
func testAccCheckResourceGridscaleNetworkExists(n string, object *gsclient.Network) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]

Expand Down Expand Up @@ -74,7 +74,7 @@ func testAccCheckDataSourceGridscaleNetworkExists(n string, object *gsclient.Net
}
}

func testAccCheckDataSourceGridscaleNetworkDestroyCheck(s *terraform.State) error {
func testAccCheckGridscaleNetworkDestroyCheck(s *terraform.State) error {
client := testAccProvider.Meta().(*gsclient.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "gridscale_network" {
Expand All @@ -98,15 +98,15 @@ func testAccCheckDataSourceGridscaleNetworkDestroyCheck(s *terraform.State) erro
return nil
}

func testAccCheckDataSourceGridscaleNetworkConfig_basic(name string) string {
func testAccCheckResourceGridscaleNetworkConfig_basic(name string) string {
return fmt.Sprintf(`
resource "gridscale_network" "foo" {
name = "%s"
}
`, name)
}

func testAccCheckDataSourceGridscaleNetworkConfig_basic_update() string {
func testAccCheckResourceGridscaleNetworkConfig_basic_update() string {
return fmt.Sprintf(`
resource "gridscale_network" "foo" {
name = "newname"
Expand Down
20 changes: 10 additions & 10 deletions gridscale/resource_gridscale_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import (
"github.com/gridscale/gsclient-go"
)

func TestAccDataSourceGridscaleServer_Basic(t *testing.T) {
func TestAccResourceGridscaleServer_Basic(t *testing.T) {
var object gsclient.Server
name := fmt.Sprintf("object-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataSourceGridscaleServerDestroyCheck,
CheckDestroy: testAccCheckResourceGridscaleServerDestroyCheck,
Steps: []resource.TestStep{
{
Config: testAccCheckDataSourceGridscaleServerConfig_basic(name),
Config: testAccCheckResourceGridscaleServerConfig_basic(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleServerExists("gridscale_server.foo", &object),
testAccCheckResourceGridscaleServerExists("gridscale_server.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_server.foo", "name", name),
resource.TestCheckResourceAttr(
Expand All @@ -35,9 +35,9 @@ func TestAccDataSourceGridscaleServer_Basic(t *testing.T) {
),
},
{
Config: testAccCheckDataSourceGridscaleServerConfig_basic_update(),
Config: testAccCheckResourceGridscaleServerConfig_basic_update(),
Check: resource.ComposeTestCheckFunc(
testAccCheckDataSourceGridscaleServerExists("gridscale_server.foo", &object),
testAccCheckResourceGridscaleServerExists("gridscale_server.foo", &object),
resource.TestCheckResourceAttr(
"gridscale_server.foo", "name", "newname"),
resource.TestCheckResourceAttr(
Expand All @@ -52,7 +52,7 @@ func TestAccDataSourceGridscaleServer_Basic(t *testing.T) {
})
}

func testAccCheckDataSourceGridscaleServerExists(n string, object *gsclient.Server) resource.TestCheckFunc {
func testAccCheckResourceGridscaleServerExists(n string, object *gsclient.Server) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]

Expand Down Expand Up @@ -84,7 +84,7 @@ func testAccCheckDataSourceGridscaleServerExists(n string, object *gsclient.Serv
}
}

func testAccCheckDataSourceGridscaleServerDestroyCheck(s *terraform.State) error {
func testAccCheckResourceGridscaleServerDestroyCheck(s *terraform.State) error {
client := testAccProvider.Meta().(*gsclient.Client)
for _, rs := range s.RootModule().Resources {
if rs.Type != "gridscale_server" {
Expand All @@ -108,7 +108,7 @@ func testAccCheckDataSourceGridscaleServerDestroyCheck(s *terraform.State) error
return nil
}

func testAccCheckDataSourceGridscaleServerConfig_basic(name string) string {
func testAccCheckResourceGridscaleServerConfig_basic(name string) string {
return fmt.Sprintf(`
resource "gridscale_server" "foo" {
name = "%s"
Expand All @@ -119,7 +119,7 @@ resource "gridscale_server" "foo" {
`, name)
}

func testAccCheckDataSourceGridscaleServerConfig_basic_update() string {
func testAccCheckResourceGridscaleServerConfig_basic_update() string {
return fmt.Sprintf(`
resource "gridscale_server" "foo" {
name = "newname"
Expand Down
Loading

0 comments on commit c30e3ac

Please sign in to comment.