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

Side by Side Diff: pkg/appengine/test/utils/raw_datastore_test_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 unified diff | Download patch
« no previous file with comments | « pkg/appengine/test/utils/mock_rpc.dart ('k') | pkg/appengine/tool/run_tests.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 raw_datastore_test_utils;
6
7 import 'package:gcloud/datastore.dart';
8
9 const TEST_KIND = 'TestKind';
10 const TEST_PROPERTY_KEY_PREFIX = 'test_property';
11 const TEST_LIST_PROPERTY = 'listproperty';
12 const TEST_LIST_VALUE = 'listvalue';
13 const TEST_PROPERTY_VALUE_PREFIX = 'test_property';
14
15 const TEST_INDEXED_PROPERTY = 'indexedProp';
16 const TEST_INDEXED_PROPERTY_VALUE_PREFIX = 'indexedValue';
17 const TEST_UNINDEXED_PROPERTY = 'unindexedProp';
18 const TEST_BLOB_INDEXED_PROPERTY = 'blobPropertyIndexed';
19 final TEST_BLOB_INDEXED_VALUE = new BlobValue([0xaa, 0xaa, 0xff, 0xff]);
20
21 buildKey(int i, {Function idFunction, String kind : TEST_KIND}) {
22 return new Key(
23 [new KeyElement(kind, idFunction == null ? null : idFunction(i))]);
24 }
25
26 Map<String, String> buildProperties(int i) {
27 var listValues = [
28 'foo',
29 '$TEST_LIST_VALUE$i',
30 ];
31
32 return {
33 TEST_PROPERTY_KEY_PREFIX : '$TEST_PROPERTY_VALUE_PREFIX$i',
34 TEST_LIST_PROPERTY : listValues,
35 TEST_INDEXED_PROPERTY : '$TEST_INDEXED_PROPERTY_VALUE_PREFIX$i',
36 TEST_UNINDEXED_PROPERTY : '$TEST_INDEXED_PROPERTY_VALUE_PREFIX$i',
37 TEST_BLOB_INDEXED_PROPERTY : TEST_BLOB_INDEXED_VALUE,
38 };
39 }
40
41 List<Key> buildKeys(
42 int from, int to, {Function idFunction, String kind : TEST_KIND}) {
43 var keys = [];
44 for (var i = from; i < to; i++) {
45 keys.add(buildKey(i, idFunction: idFunction, kind: kind));
46 }
47 return keys;
48 }
49
50 List<Entity> buildEntities(
51 int from, int to, {Function idFunction, String kind : TEST_KIND}) {
52 var entities = [];
53 var unIndexedProperties = new Set<String>();
54 for (var i = from; i < to; i++) {
55 var key = buildKey(i, idFunction: idFunction, kind: kind);
56 var properties = buildProperties(i);
57 unIndexedProperties.add(TEST_UNINDEXED_PROPERTY);
58 entities.add(
59 new Entity(key, properties, unIndexedProperties: unIndexedProperties));
60 }
61 return entities;
62 }
63
64 List<Entity> buildEntityWithAllProperties(
65 int from, int to, {String kind : TEST_KIND}) {
66 var us42 = const Duration(microseconds: 42);
67 var unIndexed = new Set<String>.from(['blobProperty']);
68
69 Map<String, String> buildProperties(int i) {
70 return {
71 'boolProperty' : true,
72 'intProperty' : 42,
73 'doubleProperty' : 4.2,
74 'stringProperty' : 'foobar',
75 'blobProperty' : new BlobValue([0xff, 0xff, 0xaa, 0xaa]),
76 'blobPropertyIndexed' : new BlobValue([0xaa, 0xaa, 0xff, 0xff]),
77 'dateProperty' :
78 new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true).add(us42),
79 'keyProperty' : buildKey(1, idFunction: (i) => 's$i', kind: kind),
80 'listProperty' : [
81 42,
82 4.2,
83 'foobar',
84 buildKey(1, idFunction: (i) => 's$i', kind: 'TestKind'),
85 ],
86 };
87 }
88
89 var entities = [];
90 for (var i = from; i < to; i++) {
91 var key = buildKey(i, idFunction: (i) => 'allprop$i', kind: kind);
92 var properties = buildProperties(i);
93 entities.add(new Entity(key, properties, unIndexedProperties: unIndexed));
94 }
95 return entities;
96 }
OLDNEW
« no previous file with comments | « pkg/appengine/test/utils/mock_rpc.dart ('k') | pkg/appengine/tool/run_tests.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698