Skip to content

Commit b299aa1

Browse files
committed
test for returning an error in a timeout
1 parent 17bbc21 commit b299aa1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

oci/core_instance_resource_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,40 @@ func (s *ResourceCoreInstanceTestSuite) TestAccResourceCoreInstance_preserveBoot
811811
})
812812
}
813813

814+
func (s *ResourceCoreInstanceTestSuite) TestAccResourceCoreInstance_failedByTimeout() {
815+
816+
testSteps := []resource.TestStep{
817+
// verify create of an instance with source_details and that we can get a boot volume id
818+
{
819+
Config: s.Config + `
820+
resource "oci_core_instance" "t" {
821+
availability_domain = "${data.oci_identity_availability_domains.ADs.availability_domains.0.name}"
822+
compartment_id = "${var.compartment_id}"
823+
subnet_id = "${oci_core_subnet.t.id}"
824+
hostname_label = "hostname1"
825+
source_details {
826+
source_type = "image"
827+
source_id = "${var.InstanceImageOCID[var.region]}"
828+
}
829+
shape = "VM.Standard1.8"
830+
metadata {
831+
ssh_authorized_keys = "${var.ssh_public_key}"
832+
user_data = "SWYgeW91IGNhbiBzZWUgdGhpcywgdGhlbiBpdCB3b3JrZWQgbWF5YmUuCg=="
833+
}
834+
timeouts {
835+
create = "15s"
836+
}
837+
}`,
838+
ExpectError: regexp.MustCompile("timeout while waiting for state"),
839+
},
840+
}
841+
842+
resource.Test(s.T(), resource.TestCase{
843+
Providers: s.Providers,
844+
Steps: testSteps,
845+
})
846+
}
847+
814848
func TestIsStatefulResource(t *testing.T) {
815849
var _ StatefulResource = (*InstanceResourceCrud)(nil)
816850
}

0 commit comments

Comments
 (0)