77 "fmt"
88 "log"
99 "testing"
10+ "time"
1011
1112 "github.com/hashicorp/terraform/helper/resource"
1213 "github.com/hashicorp/terraform/helper/schema"
@@ -18,6 +19,8 @@ import (
1819)
1920
2021var (
22+ expirationTimeForPar = time .Now ().UTC ().AddDate (0 , 0 , 1 ).Truncate (time .Millisecond )
23+
2124 PreauthenticatedRequestRequiredOnlyResource = PreauthenticatedRequestResourceDependencies +
2225 generateResourceFromRepresentationMap ("oci_objectstorage_preauthrequest" , "test_preauthenticated_request" , Required , Create , preauthenticatedRequestRepresentation )
2326
4548 "bucket" : Representation {repType : Required , create : testBucketName },
4649 "name" : Representation {repType : Required , create : `-tf-par` },
4750 "namespace" : Representation {repType : Required , create : `${oci_objectstorage_bucket.test_bucket.namespace}` },
48- "time_expires" : Representation {repType : Required , create : `2020-01-01T00:00:00Z` },
51+ "time_expires" : Representation {repType : Required , create : expirationTimeForPar . Format ( time . RFC3339Nano ) },
4952 "object" : Representation {repType : Optional , create : `my-test-object-1` },
5053 }
5154
@@ -84,7 +87,7 @@ func TestObjectStoragePreauthenticatedRequestResource_basic(t *testing.T) {
8487 resource .TestCheckResourceAttr (resourceName , "bucket" , testBucketName ),
8588 resource .TestCheckResourceAttr (resourceName , "name" , "-tf-par" ),
8689 resource .TestCheckResourceAttrSet (resourceName , "namespace" ),
87- resource .TestCheckResourceAttr (resourceName , "time_expires" , "2020-01-01T00:00:00Z" ),
90+ resource .TestCheckResourceAttr (resourceName , "time_expires" , expirationTimeForPar . Format ( time . RFC3339Nano ) ),
8891 ),
8992 },
9093
@@ -105,7 +108,7 @@ func TestObjectStoragePreauthenticatedRequestResource_basic(t *testing.T) {
105108 resource .TestCheckResourceAttrSet (resourceName , "namespace" ),
106109 resource .TestCheckResourceAttr (resourceName , "object" , "my-test-object-1" ),
107110 resource .TestCheckResourceAttrSet (resourceName , "time_created" ),
108- resource .TestCheckResourceAttr (resourceName , "time_expires" , "2020-01-01T00:00:00Z" ),
111+ resource .TestCheckResourceAttr (resourceName , "time_expires" , expirationTimeForPar . Format ( time . RFC3339Nano ) ),
109112 ),
110113 },
111114
@@ -126,7 +129,7 @@ func TestObjectStoragePreauthenticatedRequestResource_basic(t *testing.T) {
126129 resource .TestCheckResourceAttr (datasourceName , "preauthenticated_requests.0.name" , "-tf-par" ),
127130 resource .TestCheckResourceAttr (datasourceName , "preauthenticated_requests.0.object" , "my-test-object-1" ),
128131 resource .TestCheckResourceAttrSet (datasourceName , "preauthenticated_requests.0.time_created" ),
129- resource .TestCheckResourceAttr (datasourceName , "preauthenticated_requests.0.time_expires" , "2020-01-01 00:00:00 +0000 UTC" ),
132+ resource .TestCheckResourceAttr (datasourceName , "preauthenticated_requests.0.time_expires" , expirationTimeForPar . String () ),
130133 ),
131134 },
132135 // verify singular datasource
@@ -146,7 +149,7 @@ func TestObjectStoragePreauthenticatedRequestResource_basic(t *testing.T) {
146149 resource .TestCheckResourceAttr (singularDatasourceName , "name" , "-tf-par" ),
147150 resource .TestCheckResourceAttr (singularDatasourceName , "object" , "my-test-object-1" ),
148151 resource .TestCheckResourceAttrSet (singularDatasourceName , "time_created" ),
149- resource .TestCheckResourceAttr (singularDatasourceName , "time_expires" , "2020-01-01 00:00:00 +0000 UTC" ),
152+ resource .TestCheckResourceAttr (singularDatasourceName , "time_expires" , expirationTimeForPar . String () ),
150153 ),
151154 },
152155 // remove singular datasource from previous step so that it doesn't conflict with import tests
0 commit comments