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

Side by Side Diff: pkg/gcloud/test/db/e2e/metamodel_test_impl.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/gcloud/test/db/e2e/db_test_impl.dart ('k') | pkg/gcloud/test/db/model_db_test.dart » ('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 metamodel_test;
6
7 import 'dart:async';
8
9 import 'package:unittest/unittest.dart';
10
11 import 'package:gcloud/datastore.dart';
12 import 'package:gcloud/datastore.dart' show Key, Query, Partition;
13 import 'package:gcloud/db.dart' as db;
14 import 'package:gcloud/db/metamodel.dart';
15
16 List<Entity> buildEntitiesWithDifferentNamespaces() {
17 newKey(String namespace, String kind, int id) {
18 var partition = new Partition(namespace);
19 return new Key([new KeyElement(kind, id)], partition: partition);
20 }
21
22 newEntity(String namespace, String kind, {int id: 1}) {
23 return new Entity(newKey(namespace, kind, id), {'ping': 'pong'});
24 }
25
26 return [
27 newEntity(null, 'NullKind', id: 1),
28 newEntity(null, 'NullKind', id: 2),
29 newEntity(null, 'NullKind2', id: 1),
30 newEntity(null, 'NullKind2', id: 2),
31
32 newEntity('FooNamespace', 'FooKind', id: 1),
33 newEntity('FooNamespace', 'FooKind', id: 2),
34 newEntity('FooNamespace', 'FooKind2', id: 1),
35 newEntity('FooNamespace', 'FooKind2', id: 2),
36
37 newEntity('BarNamespace', 'BarKind', id: 1),
38 newEntity('BarNamespace', 'BarKind', id: 2),
39 newEntity('BarNamespace', 'BarKind2', id: 1),
40 newEntity('BarNamespace', 'BarKind2', id: 2),
41 ];
42 }
43
44 Future sleep(Duration duration) {
45 var completer = new Completer();
46 new Timer(duration, completer.complete);
47 return completer.future;
48 }
49
50 runTests(datastore, db.DatastoreDB store) {
51 // Shorten this name, so we don't have to break lines at 80 chars.
52 final cond = predicate;
53
54 group('e2e_db_metamodel', () {
55 test('namespaces__insert_lookup_delete', () {
56 var entities = buildEntitiesWithDifferentNamespaces();
57 var keys = entities.map((e) => e.key).toList();
58
59 return datastore.commit(inserts: entities).then((_) {
60 return sleep(const Duration(seconds: 10)).then((_) {
61 var namespaceQuery = store.query(Namespace);
62 return namespaceQuery.run().toList()
63 .then((List<Namespace> namespaces) {
64 expect(namespaces.length, 3);
65 expect(namespaces, contains(cond((ns) => ns.name == null)));
66 expect(namespaces,
67 contains(cond((ns) => ns.name == 'FooNamespace')));
68 expect(namespaces,
69 contains(cond((ns) => ns.name == 'BarNamespace')));
70
71 var futures = [];
72 for (var namespace in namespaces) {
73 var partition = store.newPartition(namespace.name);
74 var kindQuery = store.query(Kind, partition: partition);
75 futures.add(kindQuery.run().toList().then((List<Kind> kinds) {
76 expect(kinds.length, greaterThanOrEqualTo(2));
77 if (namespace.name == null) {
78 expect(kinds, contains(cond((k) => k.name == 'NullKind')));
79 expect(kinds, contains(cond((k) => k.name == 'NullKind2')));
80 } else if (namespace.name == 'FooNamespace') {
81 expect(kinds, contains(cond((k) => k.name == 'FooKind')));
82 expect(kinds, contains(cond((k) => k.name == 'FooKind2')));
83 } else if (namespace.name == 'BarNamespace') {
84 expect(kinds, contains(cond((k) => k.name == 'BarKind')));
85 expect(kinds, contains(cond((k) => k.name == 'BarKind2')));
86 }
87 }));
88 }
89 return Future.wait(futures).then((_) {
90 expect(datastore.commit(deletes: keys), completes);
91 });
92 });
93 });
94 });
95 });
96 });
97 }
98
OLDNEW
« no previous file with comments | « pkg/gcloud/test/db/e2e/db_test_impl.dart ('k') | pkg/gcloud/test/db/model_db_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698