Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
terraform-provider-one
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ims
terraform-provider-one
Commits
2b0ec56c
Commit
2b0ec56c
authored
Dec 01, 2017
by
Yann KAISER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added instance destruction check
parent
548cc776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
one/resource_vm_instance_test.go
one/resource_vm_instance_test.go
+31
-1
No files found.
one/resource_vm_instance_test.go
View file @
2b0ec56c
...
...
@@ -13,7 +13,6 @@ import (
)
func
TestAccVMInstance
(
t
*
testing
.
T
)
{
t
.
SkipNow
()
var
v
vm
.
VMData
resource
.
Test
(
t
,
resource
.
TestCase
{
IDRefreshName
:
"one_vm.test"
,
...
...
@@ -29,6 +28,7 @@ func TestAccVMInstance(t *testing.T) {
),
},
},
CheckDestroy
:
testAccCheckInstanceDestroy
,
})
}
...
...
@@ -93,3 +93,33 @@ func testAccVMInstanceExists(n string, vm *vm.VMData) resource.TestCheckFunc {
return
fmt
.
Errorf
(
"VM instance not found"
)
}
}
func
testAccCheckInstanceDestroy
(
s
*
terraform
.
State
)
error
{
session
:=
testAccProvider
.
Meta
()
.
(
*
Client
)
.
VMSession
for
_
,
rs
:=
range
s
.
RootModule
()
.
Resources
{
if
rs
.
Type
!=
"one_vm"
{
continue
}
instanceID
,
err
:=
strconv
.
Atoi
(
rs
.
Primary
.
ID
)
if
err
!=
nil
{
return
err
}
vmData
,
err
:=
session
.
GetVMState
(
instanceID
)
if
err
!=
nil
{
return
err
}
if
vmData
==
nil
{
return
nil
}
if
vmData
.
State
!=
vm
.
StateDone
{
return
fmt
.
Errorf
(
"found unterminated vm instance with id: %d"
,
instanceID
)
}
}
return
nil
}
Write
Preview
Markdown
is supported
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