Skip to content

Commit 1ed7691

Browse files
committed
updated tests to test default bucket functionality
1 parent 48940f9 commit 1ed7691

File tree

1 file changed

+12
-16
lines changed
  • packages/storage/amplify_storage_s3/example/integration_test

1 file changed

+12
-16
lines changed

packages/storage/amplify_storage_s3/example/integration_test/list_test.dart

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,25 @@ void main() {
2626
'$uniquePrefix/subdir4#file8.txt',
2727
];
2828
group('standard config', () {
29+
final mainBucket =
30+
StorageBucket.fromOutputs('Storage Integ Test main bucket');
31+
final secondaryBucket = StorageBucket.fromOutputs(
32+
'Storage Integ Test secondary bucket',
33+
);
2934
setUpAll(() async {
3035
await configure(amplifyEnvironments['main']!);
3136
for (var i = 0; i < 4; i++) {
3237
await Amplify.Storage.uploadData(
3338
path: StoragePath.fromString(uploadedPaths[i]),
3439
data: StorageDataPayload.bytes('test content'.codeUnits),
35-
bucket: StorageBucket.fromOutputs('Storage Integ Test main bucket'),
40+
bucket: mainBucket,
3641
).result;
3742
}
3843
for (var i = 4; i < 8; i++) {
3944
await Amplify.Storage.uploadData(
4045
path: StoragePath.fromString(uploadedPaths[i]),
4146
data: StorageDataPayload.bytes('test content'.codeUnits),
42-
bucket: StorageBucket.fromOutputs(
43-
'Storage Integ Test secondary bucket',
44-
),
47+
bucket: secondaryBucket,
4548
).result;
4649
}
4750
for (final path in uploadedPaths) {
@@ -51,15 +54,14 @@ void main() {
5154

5255
group('list() without options', () {
5356
testWidgets('should list all files with unique prefix', (_) async {
57+
// this will use the main bucket by default when no optional bucket is specified
5458
final listResultMainBucket = await Amplify.Storage.list(
5559
path: StoragePath.fromString(uniquePrefix),
5660
).result;
5761
final listResultSecondaryBucket = await Amplify.Storage.list(
5862
path: StoragePath.fromString(uniquePrefix),
5963
options: StorageListOptions(
60-
bucket: StorageBucket.fromOutputs(
61-
'Storage Integ Test secondary bucket',
62-
),
64+
bucket: secondaryBucket,
6365
),
6466
).result;
6567
for (var i = 0; i < 4; i++) {
@@ -135,9 +137,7 @@ void main() {
135137
excludeSubPaths: true,
136138
delimiter: '#',
137139
),
138-
bucket: StorageBucket.fromOutputs(
139-
'Storage Integ Test secondary bucket',
140-
),
140+
bucket: secondaryBucket,
141141
),
142142
).result as S3ListResult;
143143

@@ -181,9 +181,7 @@ void main() {
181181
path: StoragePath.fromString(uniquePrefix),
182182
options: StorageListOptions(
183183
pageSize: 2,
184-
bucket: StorageBucket.fromOutputs(
185-
'Storage Integ Test secondary bucket',
186-
),
184+
bucket: secondaryBucket,
187185
),
188186
).result;
189187

@@ -233,9 +231,7 @@ void main() {
233231
path: StoragePath.fromString(uniquePrefix),
234232
options: StorageListOptions(
235233
pluginOptions: const S3ListPluginOptions.listAll(),
236-
bucket: StorageBucket.fromOutputs(
237-
'Storage Integ Test secondary bucket',
238-
),
234+
bucket: secondaryBucket,
239235
),
240236
).result;
241237

0 commit comments

Comments
 (0)