@@ -608,23 +608,10 @@ func (t *s3CSIMountOptionsTestSuite) DefineTests(driver storageframework.TestDri
608
608
// List objects in the bucket to verify the object was created under the prefix
609
609
ginkgo .By (fmt .Sprintf ("Verifying object exists under prefix %s in bucket" , prefix ))
610
610
611
- prefixListOutput , err := s3Client .ListObjectsWithPrefix (ctx , bucketName , prefix )
612
- framework .ExpectNoError (err , "Failed to list objects with prefix" )
613
-
614
- // Verify object exists under the prefix
615
- foundObjectUnderPrefix := false
616
- expectedKey := prefix + testFileName
617
- for _ , obj := range prefixListOutput .Contents {
618
- if * obj .Key == expectedKey {
619
- foundObjectUnderPrefix = true
620
- break
621
- }
622
- }
623
- if ! foundObjectUnderPrefix {
624
- framework .Failf ("Object %s not found under prefix %s in bucket %s" , testFileName , prefix , bucketName )
625
- } else {
626
- framework .Logf ("Successfully found object %s under prefix %s in bucket %s" , testFileName , prefix , bucketName )
627
- }
611
+ // Use s3client's VerifyObjectsExistInS3 method instead of manual listing and checking
612
+ err = s3Client .VerifyObjectsExistInS3 (ctx , bucketName , prefix , []string {testFileName })
613
+ framework .ExpectNoError (err , "Failed to verify object exists under prefix %s" , prefix )
614
+ framework .Logf ("Successfully found object %s under prefix %s in bucket %s" , testFileName , prefix , bucketName )
628
615
629
616
// List objects in the bucket without the prefix to verify no objects exist at the root
630
617
ginkgo .By ("Verifying no objects exist at the root of the bucket" )
0 commit comments