-
Notifications
You must be signed in to change notification settings - Fork 14
/
resource_contentful_space_test.go
60 lines (51 loc) · 1.42 KB
/
resource_contentful_space_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
contentful "github.com/tolgaakyuz/contentful-go"
)
func TestAccContentfulSpace_Basic(t *testing.T) {
t.Skip()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckContentfulSpaceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccContentfulSpaceConfig,
Check: resource.TestCheckResourceAttr(
"contentful_space.myspace", "name", "TF Acc Test Space"),
},
resource.TestStep{
Config: testAccContentfulSpaceUpdateConfig,
Check: resource.TestCheckResourceAttr(
"contentful_space.myspace", "name", "TF Acc Test Changed Space"),
},
},
})
}
func testAccCheckContentfulSpaceDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*contentful.Contentful)
for _, rs := range s.RootModule().Resources {
if rs.Type != "contentful_space" {
continue
}
space, err := client.Spaces.Get(rs.Primary.ID)
if err == nil {
return fmt.Errorf("Space %s still exists after destroy", space.Sys.ID)
}
}
return nil
}
var testAccContentfulSpaceConfig = `
resource "contentful_space" "myspace" {
name = "TF Acc Test Space"
}
`
var testAccContentfulSpaceUpdateConfig = `
resource "contentful_space" "myspace" {
name = "TF Acc Test Changed Space"
}
`