Chromium Code Reviews| Index: test/db/db_test.dart |
| diff --git a/test/db/db_test.dart b/test/db/db_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..148f4c160e0b201be0b1ea9802d1509d13bcca24 |
| --- /dev/null |
| +++ b/test/db/db_test.dart |
| @@ -0,0 +1,51 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library gcloud.db_test; |
| + |
| +import 'package:gcloud/db.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +@Kind() |
| +class Foobar extends Model {} |
| + |
| +main() { |
| + group('db', () { |
| + test('default-partition', () { |
| + var db = new DatastoreDB(null); |
| + |
| + // Test defaultPartition |
| + expect(db.defaultPartition.namespace, isNull); |
| + |
| + // Test emptyKey |
| + expect(db.emptyKey.partition.namespace, isNull); |
| + |
| + // Test emptyKey.append() |
| + var key = db.emptyKey.append(Foobar, id: 42); |
| + expect(key.parent, db.emptyKey); |
| + expect(key.partition.namespace, isNull); |
| + expect(key.id, 42); |
| + expect(key.type, equals(Foobar)); |
| + }); |
| + |
| + test('replace-default-partition', () { |
| + var db = new DatastoreDB(null); |
|
Søren Gjesse
2015/02/19 11:59:51
Maybe duplicate this test with:
var nsDb = new Da
kustermann
2015/02/19 12:17:11
No need to duplicate it now, since I've removed th
|
| + var nsDb = db.replace( |
| + defaultPartition: new Partition('foobar-namespace')); |
| + |
| + // Test defaultPartition |
| + expect(nsDb.defaultPartition.namespace, 'foobar-namespace'); |
| + |
| + // Test emptyKey |
| + expect(nsDb.emptyKey.partition.namespace, 'foobar-namespace'); |
| + |
| + // Test emptyKey.append() |
| + var key = nsDb.emptyKey.append(Foobar, id: 42); |
| + expect(key.parent, nsDb.emptyKey); |
| + expect(key.partition.namespace, 'foobar-namespace'); |
| + expect(key.id, 42); |
| + expect(key.type, equals(Foobar)); |
| + }); |
| + }); |
| +} |