@@ -22,7 +22,7 @@ func TestAccGitlabDeployKey_basic(t *testing.T) {
22
22
Steps : []resource.TestStep {
23
23
// Create a project and deployKey with default options
24
24
{
25
- Config : testAccGitlabDeployKeyConfig (rInt ),
25
+ Config : testAccGitlabDeployKeyConfig (rInt , "" ),
26
26
Check : resource .ComposeTestCheckFunc (
27
27
testAccCheckGitlabDeployKeyExists ("gitlab_deploy_key.foo" , & deployKey ),
28
28
testAccCheckGitlabDeployKeyAttributes (& deployKey , & testAccGitlabDeployKeyExpectedAttributes {
@@ -44,7 +44,7 @@ func TestAccGitlabDeployKey_basic(t *testing.T) {
44
44
},
45
45
// Update the project deployKey to toggle the options back
46
46
{
47
- Config : testAccGitlabDeployKeyConfig (rInt ),
47
+ Config : testAccGitlabDeployKeyConfig (rInt , "" ),
48
48
Check : resource .ComposeTestCheckFunc (
49
49
testAccCheckGitlabDeployKeyExists ("gitlab_deploy_key.foo" , & deployKey ),
50
50
testAccCheckGitlabDeployKeyAttributes (& deployKey , & testAccGitlabDeployKeyExpectedAttributes {
@@ -57,6 +57,22 @@ func TestAccGitlabDeployKey_basic(t *testing.T) {
57
57
})
58
58
}
59
59
60
+ func TestAccGitlabDeployKey_suppressfunc (t * testing.T ) {
61
+ rInt := acctest .RandInt ()
62
+
63
+ resource .Test (t , resource.TestCase {
64
+ PreCheck : func () { testAccPreCheck (t ) },
65
+ Providers : testAccProviders ,
66
+ CheckDestroy : testAccCheckGitlabDeployKeyDestroy ,
67
+ Steps : []resource.TestStep {
68
+ // Create a project and deployKey with newline as suffix
69
+ {
70
+ Config : testAccGitlabDeployKeyConfig (rInt , "\\ n" ),
71
+ },
72
+ },
73
+ })
74
+ }
75
+
60
76
func testAccCheckGitlabDeployKeyExists (n string , deployKey * gitlab.DeployKey ) resource.TestCheckFunc {
61
77
return func (s * terraform.State ) error {
62
78
rs , ok := s .RootModule ().Resources [n ]
@@ -131,7 +147,7 @@ func testAccCheckGitlabDeployKeyDestroy(s *terraform.State) error {
131
147
return nil
132
148
}
133
149
134
- func testAccGitlabDeployKeyConfig (rInt int ) string {
150
+ func testAccGitlabDeployKeyConfig (rInt int , suffix string ) string {
135
151
return fmt .Sprintf (`
136
152
resource "gitlab_project" "foo" {
137
153
name = "foo-%d"
@@ -145,9 +161,9 @@ resource "gitlab_project" "foo" {
145
161
resource "gitlab_deploy_key" "foo" {
146
162
project = "${gitlab_project.foo.id}"
147
163
title = "deployKey-%d"
148
- key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCj13ozEBZ0s4el4k6mYqoyIKKKMh9hHY0sAYqSPXs2zGuVFZss1P8TPuwmdXVjHR7TiRXwC49zDrkyWJgiufggYJ1VilOohcMOODwZEJz+E5q4GCfHuh90UEh0nl8B2R0Uoy0LPeg93uZzy0hlHApsxRf/XZJz/1ytkZvCtxdllxfImCVxJReMeRVEqFCTCvy3YuJn0bce7ulcTFRvtgWOpQsr6GDK8YkcCCv2eZthVlrEwy6DEpAKTRiRLGgUj4dPO0MmO4cE2qD4ualY01PhNORJ8Q++I+EtkGt/VALkecwFuBkl18/gy+yxNJHpKc/8WVVinDeFrd/HhiY9yU0d [email protected] "
164
+ key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCj13ozEBZ0s4el4k6mYqoyIKKKMh9hHY0sAYqSPXs2zGuVFZss1P8TPuwmdXVjHR7TiRXwC49zDrkyWJgiufggYJ1VilOohcMOODwZEJz+E5q4GCfHuh90UEh0nl8B2R0Uoy0LPeg93uZzy0hlHApsxRf/XZJz/1ytkZvCtxdllxfImCVxJReMeRVEqFCTCvy3YuJn0bce7ulcTFRvtgWOpQsr6GDK8YkcCCv2eZthVlrEwy6DEpAKTRiRLGgUj4dPO0MmO4cE2qD4ualY01PhNORJ8Q++I+EtkGt/VALkecwFuBkl18/gy+yxNJHpKc/8WVVinDeFrd/HhiY9yU0d [email protected] %s "
149
165
}
150
- ` , rInt , rInt )
166
+ ` , rInt , rInt , suffix )
151
167
}
152
168
153
169
func testAccGitlabDeployKeyUpdateConfig (rInt int ) string {
0 commit comments