Skip to content

Commit cdbe3e4

Browse files
authored
Remove allocateIds implementation from fake_gcloud. (#8651)
1 parent f1ddf64 commit cdbe3e4

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

pkg/fake_gcloud/lib/mem_datastore.dart

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:convert';
2-
import 'dart:math' as math;
32
import 'dart:typed_data';
43

54
import 'package:gcloud/common.dart';
@@ -15,20 +14,11 @@ final _maxPropertyLength = 1024 * 1024;
1514
/// or read.
1615
class MemDatastore implements Datastore {
1716
final _entities = <Key, Entity>{};
18-
int _unusedId = 0;
1917

2018
@override
2119
Future<List<Key>> allocateIds(List<Key> keys) async {
22-
return keys.map((k) {
23-
if (k.elements.last.id == null) {
24-
final elements = List.of(k.elements);
25-
final last = elements.removeLast();
26-
elements.add(KeyElement(last.kind, _unusedId++));
27-
return Key(elements, partition: k.partition);
28-
} else {
29-
return k;
30-
}
31-
}).toList();
20+
throw UnimplementedError(
21+
'fake_gcloud.Datastore.allocateIds is not implemented.');
3222
}
3323

3424
@override
@@ -286,7 +276,6 @@ class MemDatastore implements Datastore {
286276
_entities.forEach((_, entity) {
287277
sink.writeln(json.encode({'entity': _encodeEntity(entity)}));
288278
});
289-
sink.writeln(json.encode({'_unusedId': _unusedId}));
290279
}
291280

292281
/// Reads content as a line-by-line JSON-encoded data format.
@@ -296,9 +285,6 @@ class MemDatastore implements Datastore {
296285
final map = json.decode(line) as Map<String, dynamic>;
297286
final key = map.keys.single;
298287
switch (key) {
299-
case '_unusedId':
300-
_unusedId = math.max(_unusedId, map[key] as int);
301-
break;
302288
case 'entity':
303289
final entity = _decodeEntity(map[key] as Map<String, dynamic>);
304290
_entities[entity.key] = entity;

pkg/fake_gcloud/test/mem_datastore_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void main() {
269269
test('write and read', () async {
270270
final sb = StringBuffer();
271271
store.writeTo(sb);
272-
expect(sb.length, 470);
272+
expect(sb.length, 454);
273273
final newStore = MemDatastore()..readFrom(sb.toString().split('\n'));
274274
final newDb = DatastoreDB(newStore);
275275

0 commit comments

Comments
 (0)