Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Unified Diff: test/db/db_test.dart

Issue 937133002: Add DatastoreDB.replace({defaultPartition}) (Closed) Base URL: git@github.com:dart-lang/gcloud.git@master
Patch Set: Addressed comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..70320d7ac585a00a7ad018d5e95d8f8ee442c13f
--- /dev/null
+++ b/test/db/db_test.dart
@@ -0,0 +1,50 @@
+// 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('non-default-partition', () {
+ var nsDb = new DatastoreDB(
+ null, 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));
+ });
+ });
+}
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698