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

Side by Side Diff: Tools/GardeningServer/scripts/model_unittests.js

Issue 173133003: Convert garden-o-matic guts over to promises where appropriate (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update to ToT Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Tools/GardeningServer/scripts/model.js ('k') | Tools/GardeningServer/scripts/results.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 var simulator = new NetworkSimulator(); 121 var simulator = new NetworkSimulator();
122 122
123 simulator.xml = function(url) 123 simulator.xml = function(url)
124 { 124 {
125 var parser = new DOMParser(); 125 var parser = new DOMParser();
126 var responseDOM = parser.parseFromString(kExampleCommitDataXML, "applica tion/xml"); 126 var responseDOM = parser.parseFromString(kExampleCommitDataXML, "applica tion/xml");
127 return Promise.resolve(responseDOM); 127 return Promise.resolve(responseDOM);
128 }; 128 };
129 129
130 simulator.runTest(function() { 130 simulator.runTest(function() {
131 model.updateRecentCommits(function() { 131 model.updateRecentCommits().then(function() {
132 var recentCommits = model.state.recentCommits; 132 var recentCommits = model.state.recentCommits;
133 delete model.state.recentCommits; 133 delete model.state.recentCommits;
134 $.each(recentCommits, function(index, commitData) { 134 $.each(recentCommits, function(index, commitData) {
135 delete commitData.message; 135 delete commitData.message;
136 }); 136 });
137 deepEqual(recentCommits, [{ 137 deepEqual(recentCommits, [{
138 "revision": 3, 138 "revision": 3,
139 "title": "This matches Gecko's behavior for these types of prope rties.", 139 "title": "This matches Gecko's behavior for these types of prope rties.",
140 "time": "2013-09-30T20:22:01Z", 140 "time": "2013-09-30T20:22:01Z",
141 "summary": "This matches Gecko's behavior for these types of pro perties.", 141 "summary": "This matches Gecko's behavior for these types of pro perties.",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 var simulator = new NetworkSimulator(); 173 var simulator = new NetworkSimulator();
174 174
175 simulator.xml = function(url) 175 simulator.xml = function(url)
176 { 176 {
177 var parser = new DOMParser(); 177 var parser = new DOMParser();
178 var responseDOM = parser.parseFromString(kExampleCommitDataXML, "applica tion/xml"); 178 var responseDOM = parser.parseFromString(kExampleCommitDataXML, "applica tion/xml");
179 return Promise.resolve(responseDOM); 179 return Promise.resolve(responseDOM);
180 }; 180 };
181 181
182 simulator.runTest(function() { 182 simulator.runTest(function() {
183 model.updateRecentCommits(function() { 183 model.updateRecentCommits().then(function() {
184 function extractBugIDs(commitData) 184 function extractBugIDs(commitData)
185 { 185 {
186 return commitData.bugID; 186 return commitData.bugID;
187 } 187 }
188 188
189 deepEqual(model.commitDataListForRevisionRange(3, 3).map(extractBugI Ds), [13]); 189 deepEqual(model.commitDataListForRevisionRange(3, 3).map(extractBugI Ds), [13]);
190 deepEqual(model.commitDataListForRevisionRange(1, 3).map(extractBugI Ds), [11, 12, 13]); 190 deepEqual(model.commitDataListForRevisionRange(1, 3).map(extractBugI Ds), [11, 12, 13]);
191 deepEqual(model.commitDataListForRevisionRange(0, 1).map(extractBugI Ds), [11]); 191 deepEqual(model.commitDataListForRevisionRange(0, 1).map(extractBugI Ds), [11]);
192 deepEqual(model.commitDataListForRevisionRange(0, 4).map(extractBugI Ds), [11, 12, 13]); 192 deepEqual(model.commitDataListForRevisionRange(0, 4).map(extractBugI Ds), [11, 12, 13]);
193 deepEqual(model.commitDataListForRevisionRange(4, 0).map(extractBugI Ds), []); 193 deepEqual(model.commitDataListForRevisionRange(4, 0).map(extractBugI Ds), []);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 'Mr. Beasley': { }, 233 'Mr. Beasley': { },
234 'Mr Dixon': {blink_revision: '2'}, 234 'Mr Dixon': {blink_revision: '2'},
235 'Mr. Sabatini': {blink_revision: '4'}, 235 'Mr. Sabatini': {blink_revision: '4'},
236 'Bob': {blink_revision: '6'} 236 'Bob': {blink_revision: '6'}
237 }; 237 };
238 equals(model.latestRevisionWithNoBuildersInFlight(), 2); 238 equals(model.latestRevisionWithNoBuildersInFlight(), 2);
239 model.state.resultsByBuilder = unmock; 239 model.state.resultsByBuilder = unmock;
240 }); 240 });
241 241
242 })(); 242 })();
OLDNEW
« no previous file with comments | « Tools/GardeningServer/scripts/model.js ('k') | Tools/GardeningServer/scripts/results.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698