1 /* 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 27 (function () { 28 29 module("rollbot"); 30 31 var kSearchResults = { 32 "cursor": "long_string_we_call_cursor", 33 "results": [ 34 { 35 "description": "Blink roll 151668:151677\n\nhttp:\/\/build.chromium.org\/f\/chromium\/perf\/dashboard\/ui\/changelog_blink.html?url=\/trunk&range=151669:151677&mode=html\nTBR=\nBUG=", 36 "cc": [ 37 "chromium-reviews (at) chromium.org", 38 ], 39 "reviewers": [ 40 ], 41 "messages": [ 42 { 43 "sender": "eseidel (at) chromium.org", 44 "recipients": [ 45 "eseidel (at) chromium.org", 46 "chromium-reviews (at) chromium.org", 47 ], 48 "text": "This roll was automatically created by the Blink AutoRollBot (crbug.com\/242461).\nInclude STOP in this message, but should be ignored.", 49 "disapproval": false, 50 "date": "2013-06-03 18:14:34.033780", 51 "approval": false 52 }, 53 ], 54 "owner_email": "eseidel (at) chromium.org", 55 "private": false, 56 "base_url": "https:\/\/chromium.googlesource.com\/chromium\/src.git@master", 57 "owner": "eseidel", 58 "subject": "Blink roll 151668:151677", 59 "created": "2013-06-03 18:14:28.926040", 60 "patchsets": [ 61 1 62 ], 63 "modified": "2013-06-03 18:14:46.869990", 64 "closed": false, 65 "commit": true, 66 "issue": 16337011 67 }, 68 { 69 "description": "Add --json-output option to layout_test_wrapper.py\n\nBUG=238381", 70 "cc": [ 71 "chromium-reviews (at) chromium.org", 72 ], 73 "reviewers": [ 74 "iannucci (at) chromium.org" 75 ], 76 "messages": [ 77 { 78 "sender": "eseidel (at) chromium.org", 79 "recipients": [ 80 "eseidel (at) chromium.org", 81 "chromium-reviews (at) chromium.org", 82 ], 83 "text": "I'm not quite sure how to test this code.\n\nI'm also ", 84 "disapproval": false, 85 "date": "2013-05-30 23:42:39.309160", 86 "approval": false 87 }, 88 ] 89 } 90 ] 91 }; 92 93 var kStoppedIssue = { 94 "description": "Blink roll 152079:152080\n\nhttp:\/\/build.chromium.org\/f\/chromium\/perf\/dashboard\/ui\/changelog_blink.html?url=\/trunk&range=152080:152080&mode=html\nTBR=\nBUG=", 95 "cc": [ 96 "chromium-reviews (at) chromium.org", 97 "none (channel is sheriff)@chromium.org" 98 ], 99 "reviewers": [ 100 "ilevy (at) chromium.org" 101 ], 102 "messages": [ 103 { 104 "sender": "eseidel (at) chromium.org", 105 "recipients": [ 106 "eseidel (at) chromium.org", 107 "chromium-reviews (at) chromium.org", 108 ], 109 "text": "This string has STOP in it, but should be ignored as the first message.", 110 "date": "2013-06-09 06:47:35.825820", 111 }, 112 { 113 "sender": "commit-bot (at) chromium.org", 114 "recipients": [ 115 "eseidel (at) chromium.org", 116 "chromium-reviews (at) chromium.org", 117 ], 118 "text": "CQ is trying da patch. Follow status at\nhttps:\/\/chromium-status.appspot.com\/cq\/eseidel (at) chromium.org\/16606004\/1", 119 "date": "2013-06-09 06:47:45.529170", 120 }, 121 { 122 "sender": "ilevy (at) chromium.org", 123 "recipients": [ 124 "eseidel (at) chromium.org", 125 "ilevy (at) chromium.org", 126 "chromium-reviews (at) chromium.org", 127 ], 128 "text": "STOP", 129 "date": "2013-06-09 07:59:48.280360", 130 }, 131 { 132 "sender": "eseidel (at) chromium.org", 133 "recipients": [ 134 "eseidel (at) chromium.org", 135 "ilevy (at) chromium.org", 136 "chromium-reviews (at) chromium.org", 137 ], 138 "text": "Rollbot was stopped by the presence of \"STOP\" in an earlier comment on this issue.\n", 139 "date": "2013-06-10 19:35:44.710470", 140 } 141 ], 142 "owner_email": "eseidel (at) chromium.org", 143 "private": false, 144 "base_url": "https:\/\/chromium.googlesource.com\/chromium\/src.git@master", 145 "owner": "eseidel", 146 "subject": "Blink roll 152079:152080", 147 "created": "2013-06-09 06:47:31.518010", 148 "patchsets": [ 149 1 150 ], 151 "modified": "2013-06-10 19:56:59.618710", 152 "closed": true, 153 "commit": false, 154 "issue": 16606004 155 }; 156 157 test("fetchCurrentRoll", 6, function() { 158 var simulator = new NetworkSimulator(); 159 simulator.get = function(url, callback) 160 { 161 simulator.scheduleCallback(function() { 162 callback(kSearchResults); 163 }); 164 }; 165 166 simulator.runTest(function() { 167 rollbot.fetchCurrentRoll(function(roll) { 168 equals(roll.issue, 16337011); 169 equals(roll.url, "https://codereview.chromium.org/16337011"); 170 equals(roll.isStopped, false); 171 equals(roll.fromRevision, "151668"); 172 equals(roll.toRevision, "151677"); 173 }); 174 }); 175 }); 176 177 test("_isRollbotStopped", 1, function() { 178 equals(true, rollbot._isRollbotStopped(kStoppedIssue)); 179 }); 180 181 })(); 182