| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 Use of this source code is governed by a BSD-style license that can be | |
| 4 found in the LICENSE file. | |
| 5 --> | |
| 6 | |
| 7 <link rel="import" href="../revisions.html"> | |
| 8 | |
| 9 <script> | |
| 10 (function () { | |
| 11 | |
| 12 var assert = chai.assert; | |
| 13 | |
| 14 var REVISION_JSON = { | |
| 15 "latest_builder_info": { | |
| 16 "Group 1": { | |
| 17 "Bot A": { | |
| 18 "state": "building", | |
| 19 "lastUpdateTime": 0, | |
| 20 "revisions": { | |
| 21 "v8": 100, | |
| 22 "chromium": 200, | |
| 23 "nacl": 300, | |
| 24 "blink": 400 | |
| 25 } | |
| 26 }, | |
| 27 "Bot B": { | |
| 28 "state": "building", | |
| 29 "lastUpdateTime": 0, | |
| 30 "revisions": { | |
| 31 "v8": 101, | |
| 32 "chromium": 201, | |
| 33 "nacl": 301, | |
| 34 "blink": 401 | |
| 35 } | |
| 36 }, | |
| 37 }, | |
| 38 "Group 2": { | |
| 39 "Bot A": { | |
| 40 "state": "building", | |
| 41 "lastUpdateTime": 0, | |
| 42 "revisions": { | |
| 43 "v8": 102, | |
| 44 "chromium": 203, | |
| 45 "nacl": 304, | |
| 46 "blink": 405 | |
| 47 } | |
| 48 }, | |
| 49 "Bot B": { | |
| 50 "state": "building", | |
| 51 "lastUpdateTime": 0, | |
| 52 "revisions": { | |
| 53 "v8": 103, | |
| 54 "chromium": 203, | |
| 55 "nacl": 303, | |
| 56 "blink": 403 | |
| 57 } | |
| 58 }, | |
| 59 "Bot C": { | |
| 60 "state": "building", | |
| 61 "lastUpdateTime": 0, | |
| 62 "revisions": { | |
| 63 "v8": 104, | |
| 64 "chromium": 204, | |
| 65 "nacl": 304, | |
| 66 "blink": 404 | |
| 67 } | |
| 68 } | |
| 69 } | |
| 70 } | |
| 71 }; | |
| 72 | |
| 73 describe('bot revisions', function() { | |
| 74 describe('Parsing', function() { | |
| 75 it('Should parse groups in JSON data correctly.', function(done) { | |
| 76 revisions.parseBuildInfo(REVISION_JSON).then(function(parsedData) { | |
| 77 assert.equal(parsedData.groups.length, 2); | |
| 78 assert.equal(parsedData.groups[0].name, 'Group 1'); | |
| 79 assert.equal(parsedData.groups[1].name, 'Group 2'); | |
| 80 }).then(done).catch(function(error) { | |
| 81 assert(false, 'Failed to parse JSON data.'); | |
| 82 }).catch(done); | |
| 83 }); | |
| 84 it('Should parse builders in a group correctly.', function(done) { | |
| 85 revisions.parseBuildInfo(REVISION_JSON).then(function(parsedData) { | |
| 86 var group1 = parsedData.groups[0]; | |
| 87 assert.equal(group1.builders.length, 2); | |
| 88 assert.equal(group1.builders[0].name, 'Bot A'); | |
| 89 assert.equal(group1.builders[1].name, 'Bot B'); | |
| 90 var group2 = parsedData.groups[1]; | |
| 91 assert.equal(group2.builders.length, 3); | |
| 92 assert.equal(group2.builders[0].name, 'Bot A'); | |
| 93 assert.equal(group2.builders[1].name, 'Bot B'); | |
| 94 assert.equal(group2.builders[2].name, 'Bot C'); | |
| 95 }).then(done, done); | |
| 96 }); | |
| 97 it('Should parse revision data for a builder correctly.', function(done) { | |
| 98 revisions.parseBuildInfo(REVISION_JSON).then(function(parsedData) { | |
| 99 var bot1A = parsedData.groups[0].builders[0]; | |
| 100 assert.equal(bot1A.status, 'building'); | |
| 101 assert.equal(bot1A.repositories[0].name, 'chromium'); | |
| 102 assert.equal(bot1A.repositories[0].revision, 200); | |
| 103 assert.equal(bot1A.repositories[1].name, 'blink'); | |
| 104 assert.equal(bot1A.repositories[1].revision, 400); | |
| 105 assert.equal(bot1A.repositories[2].name, 'v8'); | |
| 106 assert.equal(bot1A.repositories[2].revision, 100); | |
| 107 assert.equal(bot1A.repositories[3].name, 'nacl'); | |
| 108 assert.equal(bot1A.repositories[3].revision, 300); | |
| 109 | |
| 110 var bot2C = parsedData.groups[1].builders[2]; | |
| 111 assert.equal(bot2C.status, 'building'); | |
| 112 assert.equal(bot2C.repositories[0].name, 'chromium'); | |
| 113 assert.equal(bot2C.repositories[0].revision, 204); | |
| 114 assert.equal(bot2C.repositories[1].name, 'blink'); | |
| 115 assert.equal(bot2C.repositories[1].revision, 404); | |
| 116 assert.equal(bot2C.repositories[2].name, 'v8'); | |
| 117 assert.equal(bot2C.repositories[2].revision, 104); | |
| 118 assert.equal(bot2C.repositories[3].name, 'nacl'); | |
| 119 assert.equal(bot2C.repositories[3].revision, 304); | |
| 120 | |
| 121 }).then(done, done); | |
| 122 }); | |
| 123 }); | |
| 124 | |
| 125 describe('Builder URIs', function() { | |
| 126 it('Should construct proper buildbot URIs.', function(done) { | |
| 127 revisions.parseBuildInfo(REVISION_JSON).then(function(parsedData) { | |
| 128 var bot1A = parsedData.groups[0].builders[0]; | |
| 129 assert.equal(bot1A.uri, | |
| 130 'https://build.chromium.org/p/Group 1/builders/Bot A'); | |
| 131 var bot2B = parsedData.groups[1].builders[1]; | |
| 132 assert.equal(bot2B.uri, | |
| 133 'https://build.chromium.org/p/Group 2/builders/Bot B'); | |
| 134 }).then(done, done); | |
| 135 }); | |
| 136 it('Should construct proper revision URIs.', function(done) { | |
| 137 revisions.parseBuildInfo(REVISION_JSON).then(function(parsedData) { | |
| 138 var bot1A = parsedData.groups[0].builders[0]; | |
| 139 assert.equal(bot1A.repositories[0].uri, | |
| 140 'https://chromium.googlesource.com/chromium/src/+/200'); | |
| 141 assert.equal(bot1A.repositories[1].uri, | |
| 142 'https://src.chromium.org/viewvc/blink/?pathrev=400'); | |
| 143 }).then(done, done); | |
| 144 }); | |
| 145 }); | |
| 146 }); | |
| 147 })() | |
| 148 </script> | |
| OLD | NEW |