OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library gcloud.db_test; |
| 6 |
| 7 import 'package:gcloud/db.dart'; |
| 8 import 'package:unittest/unittest.dart'; |
| 9 |
| 10 @Kind() |
| 11 class Foobar extends Model {} |
| 12 |
| 13 main() { |
| 14 group('db', () { |
| 15 test('default-partition', () { |
| 16 var db = new DatastoreDB(null); |
| 17 |
| 18 // Test defaultPartition |
| 19 expect(db.defaultPartition.namespace, isNull); |
| 20 |
| 21 // Test emptyKey |
| 22 expect(db.emptyKey.partition.namespace, isNull); |
| 23 |
| 24 // Test emptyKey.append() |
| 25 var key = db.emptyKey.append(Foobar, id: 42); |
| 26 expect(key.parent, db.emptyKey); |
| 27 expect(key.partition.namespace, isNull); |
| 28 expect(key.id, 42); |
| 29 expect(key.type, equals(Foobar)); |
| 30 }); |
| 31 |
| 32 test('non-default-partition', () { |
| 33 var nsDb = new DatastoreDB( |
| 34 null, defaultPartition: new Partition('foobar-namespace')); |
| 35 |
| 36 // Test defaultPartition |
| 37 expect(nsDb.defaultPartition.namespace, 'foobar-namespace'); |
| 38 |
| 39 // Test emptyKey |
| 40 expect(nsDb.emptyKey.partition.namespace, 'foobar-namespace'); |
| 41 |
| 42 // Test emptyKey.append() |
| 43 var key = nsDb.emptyKey.append(Foobar, id: 42); |
| 44 expect(key.parent, nsDb.emptyKey); |
| 45 expect(key.partition.namespace, 'foobar-namespace'); |
| 46 expect(key.id, 42); |
| 47 expect(key.type, equals(Foobar)); |
| 48 }); |
| 49 }); |
| 50 } |
OLD | NEW |