Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Terraform
Commits
83317975
Commit
83317975
authored
6 years ago
by
James Bardin
Browse files
Options
Download
Email Patches
Plain Diff
add more tests with carious set combinations
parent
21dfa567
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
builtin/providers/test/resource_nested_set.go
+5
-0
builtin/providers/test/resource_nested_set.go
builtin/providers/test/resource_nested_set_test.go
+85
-1
builtin/providers/test/resource_nested_set_test.go
with
90 additions
and
1 deletion
+90
-1
builtin/providers/test/resource_nested_set.go
+
5
-
0
View file @
83317975
...
...
@@ -23,6 +23,11 @@ func testResourceNestedSet() *schema.Resource {
Type
:
schema
.
TypeBool
,
Optional
:
true
,
},
"force_new"
:
{
Type
:
schema
.
TypeString
,
Optional
:
true
,
ForceNew
:
true
,
},
"single"
:
{
Type
:
schema
.
TypeSet
,
Optional
:
true
,
...
...
This diff is collapsed.
Click to expand it.
builtin/providers/test/resource_nested_set_test.go
+
85
-
1
View file @
83317975
...
...
@@ -127,7 +127,7 @@ resource "test_resource_nested_set" "foo" {
},
})
}
func
TestResourceNestedSet_multi
(
t
*
testing
.
T
)
{
func
TestResourceNestedSet_multi
AddRemove
(
t
*
testing
.
T
)
{
checkFunc
:=
func
(
s
*
terraform
.
State
)
error
{
return
nil
}
...
...
@@ -218,6 +218,90 @@ resource "test_resource_nested_set" "foo" {
`
),
Check
:
checkFunc
,
},
resource
.
TestStep
{
Config
:
strings
.
TrimSpace
(
`
resource "test_resource_nested_set" "foo" {
optional = true
single {
value = "bar"
optional = "baz"
}
multi {
set {
required = "new"
optional_int = 3
}
}
}
`
),
Check
:
checkFunc
,
},
},
})
}
func
TestResourceNestedSet_forceNewEmptyString
(
t
*
testing
.
T
)
{
var
id
string
step
:=
0
checkFunc
:=
func
(
s
*
terraform
.
State
)
error
{
root
:=
s
.
ModuleByPath
(
addrs
.
RootModuleInstance
)
res
:=
root
.
Resources
[
"test_resource_nested_set.foo"
]
defer
func
()
{
step
++
id
=
res
.
Primary
.
ID
}()
if
step
==
2
&&
res
.
Primary
.
ID
==
id
{
// setting an empty string currently does not trigger ForceNew, but
// it should in the future.
return
nil
}
if
res
.
Primary
.
ID
==
id
{
return
errors
.
New
(
"expected new resource"
)
}
return
nil
}
resource
.
UnitTest
(
t
,
resource
.
TestCase
{
Providers
:
testAccProviders
,
CheckDestroy
:
testAccCheckResourceDestroy
,
Steps
:
[]
resource
.
TestStep
{
resource
.
TestStep
{
Config
:
strings
.
TrimSpace
(
`
resource "test_resource_nested_set" "foo" {
multi {
set {
required = "val"
}
}
}
`
),
Check
:
checkFunc
,
},
resource
.
TestStep
{
Config
:
strings
.
TrimSpace
(
`
resource "test_resource_nested_set" "foo" {
multi {
set {
required = ""
}
}
}
`
),
Check
:
checkFunc
,
},
resource
.
TestStep
{
Config
:
strings
.
TrimSpace
(
`
resource "test_resource_nested_set" "foo" {
force_new = ""
}
`
),
Check
:
checkFunc
,
},
},
})
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help