OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library gcloud.storage; | 5 library gcloud.storage; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:googleapis/storage/v1.dart' as storage_api; | 9 import 'package:googleapis/storage/v1.dart' as storage_api; |
10 import 'package:gcloud/storage.dart'; | 10 import 'package:gcloud/storage.dart'; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ], (f) => f().then(expectAsync((_) {}))); | 73 ], (f) => f().then(expectAsync((_) {}))); |
74 }); | 74 }); |
75 | 75 |
76 test('create-error', () { | 76 test('create-error', () { |
77 storage.createBucket('goog-reserved').catchError(expectAsync((e) { | 77 storage.createBucket('goog-reserved').catchError(expectAsync((e) { |
78 expect(e, isNotNull); | 78 expect(e, isNotNull); |
79 }), test: testDetailedApiError); | 79 }), test: testDetailedApiError); |
80 }); | 80 }); |
81 }); | 81 }); |
82 | 82 |
83 // TODO: Remove solo_ here when the rate-limit issue have been resolved. | 83 group('object', () { |
84 solo_group('object', () { | |
85 // Run all object tests in the same bucket to try to avoid the rate-limit | 84 // Run all object tests in the same bucket to try to avoid the rate-limit |
86 // for creating and deleting buckets while testing. | 85 // for creating and deleting buckets while testing. |
87 Future withTestBucket(function) { | 86 Future withTestBucket(function) { |
88 return function(testBucket).whenComplete(() { | 87 return function(testBucket).whenComplete(() { |
89 // TODO: Clean the bucket. | 88 // TODO: Clean the bucket. |
90 }); | 89 }); |
91 } | 90 } |
92 | 91 |
93 test('create-read-delete', () { | 92 test('create-read-delete', () { |
94 Future test(name, bytes) { | 93 Future test(name, bytes) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 Acl acl1 = new Acl( | 163 Acl acl1 = new Acl( |
165 [new AclEntry(AclScope.allAuthenticated, AclPermission.WRITE)]); | 164 [new AclEntry(AclScope.allAuthenticated, AclPermission.WRITE)]); |
166 Acl acl2 = new Acl( | 165 Acl acl2 = new Acl( |
167 [new AclEntry(AclScope.allUsers, AclPermission.WRITE), | 166 [new AclEntry(AclScope.allUsers, AclPermission.WRITE), |
168 new AclEntry(new AccountScope('sgjesse@google.com'), | 167 new AclEntry(new AccountScope('sgjesse@google.com'), |
169 AclPermission.WRITE)]); | 168 AclPermission.WRITE)]); |
170 Acl acl3 = new Acl( | 169 Acl acl3 = new Acl( |
171 [new AclEntry(AclScope.allUsers, AclPermission.WRITE), | 170 [new AclEntry(AclScope.allUsers, AclPermission.WRITE), |
172 new AclEntry(new AccountScope('sgjesse@google.com'), | 171 new AclEntry(new AccountScope('sgjesse@google.com'), |
173 AclPermission.WRITE), | 172 AclPermission.WRITE), |
174 new AclEntry(new AccountScope('misc@dartlang.org'), | 173 new AclEntry(new GroupScope('misc@dartlang.org'), |
175 AclPermission.READ)]); | 174 AclPermission.READ)]); |
176 Acl acl4 = new Acl( | 175 Acl acl4 = new Acl( |
177 [new AclEntry(AclScope.allUsers, AclPermission.WRITE), | 176 [new AclEntry(AclScope.allUsers, AclPermission.WRITE), |
178 new AclEntry(new AccountScope('sgjesse@google.com'), | 177 new AclEntry(new AccountScope('sgjesse@google.com'), |
179 AclPermission.WRITE), | 178 AclPermission.WRITE), |
180 new AclEntry(new GroupScope('misc@dartlang.org'), | 179 new AclEntry(new GroupScope('misc@dartlang.org'), |
181 AclPermission.READ), | 180 AclPermission.READ), |
182 new AclEntry(new DomainScope('dartlang.org'), | 181 new AclEntry(new DomainScope('dartlang.org'), |
183 AclPermission.FULL_CONTROL)]); | 182 AclPermission.FULL_CONTROL)]); |
184 | 183 |
| 184 // The expected length of the returned ACL is one longer than the one |
| 185 // use during creation as an additional 'used-ID' ACL entry is added |
| 186 // by cloud storage during creation. |
185 return Future.forEach([ | 187 return Future.forEach([ |
186 () => test('test-1', acl1, 1), | 188 () => test('test-1', acl1, acl1.entries.length + 1), |
187 () => test('test-2', acl2, 2), | 189 () => test('test-2', acl2, acl2.entries.length + 1), |
188 () => test('test-3', acl3, 3), | 190 () => test('test-3', acl3, acl3.entries.length + 1), |
189 () => test('test-4', acl4, 4) | 191 () => test('test-4', acl4, acl4.entries.length + 1) |
190 ], (f) => f().then(expectAsync((_) {}))); | 192 ], (f) => f().then(expectAsync((_) {}))); |
191 }); | 193 }); |
192 }); | 194 }); |
193 | 195 |
194 test('create-with-metadata-delete', () { | 196 test('create-with-metadata-delete', () { |
195 return withTestBucket((Bucket bucket) { | 197 return withTestBucket((Bucket bucket) { |
196 Future test(objectName, metadata, bytes) { | 198 Future test(objectName, metadata, bytes) { |
197 return bucket.writeBytes(objectName, bytes, metadata: metadata) | 199 return bucket.writeBytes(objectName, bytes, metadata: metadata) |
198 .then(expectAsync((result) { | 200 .then(expectAsync((result) { |
199 expect(result, isNotNull); | 201 expect(result, isNotNull); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 }).whenComplete(() { | 258 }).whenComplete(() { |
257 // Deleting a bucket relies on eventually consistent behaviour, hence | 259 // Deleting a bucket relies on eventually consistent behaviour, hence |
258 // the delay in attempt to prevent test flakiness. | 260 // the delay in attempt to prevent test flakiness. |
259 return new Future.delayed(STORAGE_LIST_DELAY, () { | 261 return new Future.delayed(STORAGE_LIST_DELAY, () { |
260 return storage.deleteBucket(testBucket); | 262 return storage.deleteBucket(testBucket); |
261 }); | 263 }); |
262 }); | 264 }); |
263 }); | 265 }); |
264 }); | 266 }); |
265 } | 267 } |
OLD | NEW |