@@ -353,6 +353,52 @@ func TestAccAWSS3BucketObject_updates(t *testing.T) {
353
353
})
354
354
}
355
355
356
+ func TestAccAWSS3BucketObject_updateSameFile (t * testing.T ) {
357
+ var originalObj , modifiedObj s3.GetObjectOutput
358
+ resourceName := "aws_s3_bucket_object.object"
359
+ rInt := acctest .RandInt ()
360
+
361
+ startingData := "lane 8"
362
+ changingData := "chicane"
363
+
364
+ filename := testAccAWSS3BucketObjectCreateTempFile (t , startingData )
365
+ defer os .Remove (filename )
366
+
367
+ rewriteFile := func (* terraform.State ) error {
368
+ if err := ioutil .WriteFile (filename , []byte (changingData ), 0644 ); err != nil {
369
+ os .Remove (filename )
370
+ t .Fatal (err )
371
+ }
372
+ return nil
373
+ }
374
+
375
+ resource .ParallelTest (t , resource.TestCase {
376
+ PreCheck : func () { testAccPreCheck (t ) },
377
+ Providers : testAccProviders ,
378
+ CheckDestroy : testAccCheckAWSS3BucketObjectDestroy ,
379
+ Steps : []resource.TestStep {
380
+ {
381
+ Config : testAccAWSS3BucketObjectConfig_updateable (rInt , false , filename ),
382
+ Check : resource .ComposeTestCheckFunc (
383
+ testAccCheckAWSS3BucketObjectExists (resourceName , & originalObj ),
384
+ testAccCheckAWSS3BucketObjectBody (& originalObj , startingData ),
385
+ resource .TestCheckResourceAttr (resourceName , "etag" , "aa48b42f36a2652cbee40c30a5df7d25" ),
386
+ rewriteFile ,
387
+ ),
388
+ ExpectNonEmptyPlan : true ,
389
+ },
390
+ {
391
+ Config : testAccAWSS3BucketObjectConfig_updateable (rInt , false , filename ),
392
+ Check : resource .ComposeTestCheckFunc (
393
+ testAccCheckAWSS3BucketObjectExists (resourceName , & modifiedObj ),
394
+ testAccCheckAWSS3BucketObjectBody (& modifiedObj , changingData ),
395
+ resource .TestCheckResourceAttr (resourceName , "etag" , "fafc05f8c4da0266a99154681ab86e8c" ),
396
+ ),
397
+ },
398
+ },
399
+ })
400
+ }
401
+
356
402
func TestAccAWSS3BucketObject_updatesWithVersioning (t * testing.T ) {
357
403
var originalObj , modifiedObj s3.GetObjectOutput
358
404
resourceName := "aws_s3_bucket_object.object"
0 commit comments