import { v4 } from 'uuid' ; import { tmpdir } from 'os' ; import { Common } from '@kui-shell/test' ; import S3Utils , { README , README2 , README3 , PJSON , PROVIDER } from './util' ; export default function basics ( this ) { const { copyFromS3 , copyToS3 , ls , lsExpectingCount , lsExpecting404 , mkdir , multiCopyToS3 , rm , rmdir , rmdirExpectingError } = S3Utils . bind ( this ) ( ) ; const bucketName = `kuitest-${ v4 ( ) }` ; mkdir ( bucketName ) ; ls ( bucketName ) ; multiCopyToS3 ( bucketName ) ; ls ( PJSON , bucketName ) ; ls ( README , bucketName ) ; lsExpectingCount ( `/s3/${ PROVIDER }/${ bucketName }` , 1 , '-d' ) ; lsExpectingCount ( `/s3/${ PROVIDER }/${ bucketName }/` , 1 , '-d' ) ; lsExpectingCount ( `/s3/${ PROVIDER }/*${ bucketName . slice ( 1 ) }` , 1 , '-d' ) ; lsExpectingCount ( `/s3/${ PROVIDER }/*${ bucketName . slice ( 1 ) }/` , 1 , '-d' ) ; copyToS3 ( bucketName , README + '.fakeending' ) ; lsExpectingCount ( `/s3/${ PROVIDER }/${ bucketName }/${ README }` , 1 ) ; lsExpectingCount ( `/s3/${ PROVIDER }/${ bucketName }/${ README }.fakeending` , 1 ) ; lsExpectingCount ( `/s3/${ PROVIDER }/${ bucketName }/${ README }*` , 2 ) ; ls ( README , bucketName , '*' ) ; ls ( README , bucketName , 'R*' ) ; ls ( README , bucketName , '*EADME.md' ) ; ls ( README , bucketName , 'README{,}.md' ) ; ls ( README , bucketName , 'README{,}.m*' ) ; copyToS3 ( bucketName , README2 ) ; ls ( README2 , bucketName ) ; copyFromS3 ( bucketName , README2 . replace ( /.md$/ , '*' ) , tmpdir ( ) ) ; copyFromS3 ( bucketName , README2 , tmpdir ( ) , README3 ) ; rmdirExpectingError ( bucketName ) ; rm ( bucketName , PJSON ) ; rm ( bucketName , README . charAt ( 0 ) + '*' ) ; rmdir ( bucketName ) ; lsExpecting404 ( bucketName ) ; }