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

Unified Diff: pkg/gcloud/test/datastore/e2e/utils.dart

Issue 804973002: Add appengine/gcloud/mustache dependencies. (Closed) Base URL: git@github.com:dart-lang/pub-dartlang-dart.git@master
Patch Set: Added AUTHORS/LICENSE/PATENTS files Created 6 years 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
Index: pkg/gcloud/test/datastore/e2e/utils.dart
diff --git a/pkg/gcloud/test/datastore/e2e/utils.dart b/pkg/gcloud/test/datastore/e2e/utils.dart
new file mode 100644
index 0000000000000000000000000000000000000000..32fc4911c8e5a0efb75f0e7486a50b7dcc2959e8
--- /dev/null
+++ b/pkg/gcloud/test/datastore/e2e/utils.dart
@@ -0,0 +1,97 @@
+// Copyright (c) 2014, 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 raw_datastore_test_utils;
+
+import 'package:gcloud/datastore.dart';
+
+const TEST_KIND = 'TestKind';
+const TEST_PROPERTY_KEY_PREFIX = 'test_property';
+const TEST_LIST_PROPERTY = 'listproperty';
+const TEST_LIST_VALUE = 'listvalue';
+const TEST_PROPERTY_VALUE_PREFIX = 'test_property';
+
+const TEST_INDEXED_PROPERTY = 'indexedProp';
+const TEST_INDEXED_PROPERTY_VALUE_PREFIX = 'indexedValue';
+const TEST_UNINDEXED_PROPERTY = 'unindexedProp';
+const TEST_BLOB_INDEXED_PROPERTY = 'blobPropertyIndexed';
+final TEST_BLOB_INDEXED_VALUE = new BlobValue([0xaa, 0xaa, 0xff, 0xff]);
+
+
+buildKey(int i, {Function idFunction, String kind : TEST_KIND}) {
+ return new Key(
+ [new KeyElement(kind, idFunction == null ? null : idFunction(i))]);
+}
+
+Map<String, String> buildProperties(int i) {
+ var listValues = [
+ 'foo',
+ '$TEST_LIST_VALUE$i',
+ ];
+
+ return {
+ TEST_PROPERTY_KEY_PREFIX : '$TEST_PROPERTY_VALUE_PREFIX$i',
+ TEST_LIST_PROPERTY : listValues,
+ TEST_INDEXED_PROPERTY : '$TEST_INDEXED_PROPERTY_VALUE_PREFIX$i',
+ TEST_UNINDEXED_PROPERTY : '$TEST_INDEXED_PROPERTY_VALUE_PREFIX$i',
+ TEST_BLOB_INDEXED_PROPERTY : TEST_BLOB_INDEXED_VALUE,
+ };
+}
+
+List<Key> buildKeys(
+ int from, int to, {Function idFunction, String kind : TEST_KIND}) {
+ var keys = [];
+ for (var i = from; i < to; i++) {
+ keys.add(buildKey(i, idFunction: idFunction, kind: kind));
+ }
+ return keys;
+}
+
+List<Entity> buildEntities(
+ int from, int to, {Function idFunction, String kind : TEST_KIND}) {
+ var entities = [];
+ var unIndexedProperties = new Set<String>();
+ for (var i = from; i < to; i++) {
+ var key = buildKey(i, idFunction: idFunction, kind: kind);
+ var properties = buildProperties(i);
+ unIndexedProperties.add(TEST_UNINDEXED_PROPERTY);
+ entities.add(
+ new Entity(key, properties, unIndexedProperties: unIndexedProperties));
+ }
+ return entities;
+}
+
+List<Entity> buildEntityWithAllProperties(
+ int from, int to, {String kind : TEST_KIND}) {
+ var us42 = const Duration(microseconds: 42);
+ var unIndexed = new Set<String>.from(['blobProperty']);
+
+ Map<String, String> buildProperties(int i) {
+ return {
+ 'boolProperty' : true,
+ 'intProperty' : 42,
+ 'doubleProperty' : 4.2,
+ 'stringProperty' : 'foobar',
+ 'blobProperty' : new BlobValue([0xff, 0xff, 0xaa, 0xaa]),
+ 'blobPropertyIndexed' : new BlobValue([0xaa, 0xaa, 0xff, 0xff]),
+ 'dateProperty' :
+ new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true).add(us42),
+ 'keyProperty' : buildKey(1, idFunction: (i) => 's$i', kind: kind),
+ 'listProperty' : [
+ 42,
+ 4.2,
+ 'foobar',
+ buildKey(1, idFunction: (i) => 's$i', kind: 'TestKind'),
+ ],
+ };
+ }
+
+ var entities = [];
+ for (var i = from; i < to; i++) {
+ var key = buildKey(i, idFunction: (i) => 'allprop$i', kind: kind);
+ var properties = buildProperties(i);
+ entities.add(new Entity(key, properties, unIndexedProperties: unIndexed));
+ }
+ return entities;
+}
« no previous file with comments | « pkg/gcloud/test/datastore/e2e/datastore_test_impl.dart ('k') | pkg/gcloud/test/datastore/error_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698