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

Side by Side 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 unified diff | Download patch
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
22 buildKey(int i, {Function idFunction, String kind : TEST_KIND}) {
23 return new Key(
24 [new KeyElement(kind, idFunction == null ? null : idFunction(i))]);
25 }
26
27 Map<String, String> buildProperties(int i) {
28 var listValues = [
29 'foo',
30 '$TEST_LIST_VALUE$i',
31 ];
32
33 return {
34 TEST_PROPERTY_KEY_PREFIX : '$TEST_PROPERTY_VALUE_PREFIX$i',
35 TEST_LIST_PROPERTY : listValues,
36 TEST_INDEXED_PROPERTY : '$TEST_INDEXED_PROPERTY_VALUE_PREFIX$i',
37 TEST_UNINDEXED_PROPERTY : '$TEST_INDEXED_PROPERTY_VALUE_PREFIX$i',
38 TEST_BLOB_INDEXED_PROPERTY : TEST_BLOB_INDEXED_VALUE,
39 };
40 }
41
42 List<Key> buildKeys(
43 int from, int to, {Function idFunction, String kind : TEST_KIND}) {
44 var keys = [];
45 for (var i = from; i < to; i++) {
46 keys.add(buildKey(i, idFunction: idFunction, kind: kind));
47 }
48 return keys;
49 }
50
51 List<Entity> buildEntities(
52 int from, int to, {Function idFunction, String kind : TEST_KIND}) {
53 var entities = [];
54 var unIndexedProperties = new Set<String>();
55 for (var i = from; i < to; i++) {
56 var key = buildKey(i, idFunction: idFunction, kind: kind);
57 var properties = buildProperties(i);
58 unIndexedProperties.add(TEST_UNINDEXED_PROPERTY);
59 entities.add(
60 new Entity(key, properties, unIndexedProperties: unIndexedProperties));
61 }
62 return entities;
63 }
64
65 List<Entity> buildEntityWithAllProperties(
66 int from, int to, {String kind : TEST_KIND}) {
67 var us42 = const Duration(microseconds: 42);
68 var unIndexed = new Set<String>.from(['blobProperty']);
69
70 Map<String, String> buildProperties(int i) {
71 return {
72 'boolProperty' : true,
73 'intProperty' : 42,
74 'doubleProperty' : 4.2,
75 'stringProperty' : 'foobar',
76 'blobProperty' : new BlobValue([0xff, 0xff, 0xaa, 0xaa]),
77 'blobPropertyIndexed' : new BlobValue([0xaa, 0xaa, 0xff, 0xff]),
78 'dateProperty' :
79 new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true).add(us42),
80 'keyProperty' : buildKey(1, idFunction: (i) => 's$i', kind: kind),
81 'listProperty' : [
82 42,
83 4.2,
84 'foobar',
85 buildKey(1, idFunction: (i) => 's$i', kind: 'TestKind'),
86 ],
87 };
88 }
89
90 var entities = [];
91 for (var i = from; i < to; i++) {
92 var key = buildKey(i, idFunction: (i) => 'allprop$i', kind: kind);
93 var properties = buildProperties(i);
94 entities.add(new Entity(key, properties, unIndexedProperties: unIndexed));
95 }
96 return entities;
97 }
OLDNEW
« 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