| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package buildbot | 5 package buildbot |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "compress/zlib" | 9 "compress/zlib" |
| 10 "encoding/base64" | 10 "encoding/base64" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 { | 106 { |
| 107 Source: buildbot
SourceStamp{ | 107 Source: buildbot
SourceStamp{ |
| 108 Changes:
[]buildbotChange{{Comments: "foo"}}, | 108 Changes:
[]buildbotChange{{Comments: "foo"}}, |
| 109 }, | 109 }, |
| 110 }, | 110 }, |
| 111 }, | 111 }, |
| 112 }, | 112 }, |
| 113 }, | 113 }, |
| 114 } | 114 } |
| 115 So(putDSMasterJSON(c, m, false), ShouldBeNil) | 115 So(putDSMasterJSON(c, m, false), ShouldBeNil) |
| 116 » » » lm, _, err := getMasterJSON(c, "fake") | 116 » » » lm, _, _, err := getMasterJSON(c, "fake") |
| 117 So(err, ShouldBeNil) | 117 So(err, ShouldBeNil) |
| 118 So(lm.Builders["fake builder"].PendingBuildStates[0].Sou
rce.Changes[0].Comments, ShouldResemble, "") | 118 So(lm.Builders["fake builder"].PendingBuildStates[0].Sou
rce.Changes[0].Comments, ShouldResemble, "") |
| 119 }) | 119 }) |
| 120 | 120 |
| 121 Convey("Save build entry", func() { | 121 Convey("Save build entry", func() { |
| 122 build := &buildbotBuild{ | 122 build := &buildbotBuild{ |
| 123 Master: "Fake Master", | 123 Master: "Fake Master", |
| 124 Buildername: "Fake buildername", | 124 Buildername: "Fake buildername", |
| 125 Number: 1234, | 125 Number: 1234, |
| 126 Currentstep: "this is a string", | 126 Currentstep: "this is a string", |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 Convey("And stores correctly", func() { | 251 Convey("And stores correctly", func() { |
| 252 loadB := &buildbotBuild{ | 252 loadB := &buildbotBuild{ |
| 253 Master: "Fake Master", | 253 Master: "Fake Master", |
| 254 Buildername: "Fake buildername", | 254 Buildername: "Fake buildername", |
| 255 Number: 1234, | 255 Number: 1234, |
| 256 } | 256 } |
| 257 err := ds.Get(c, loadB) | 257 err := ds.Get(c, loadB) |
| 258 So(err, ShouldBeNil) | 258 So(err, ShouldBeNil) |
| 259 So(loadB.Master, ShouldEqual, "Fake Master") | 259 So(loadB.Master, ShouldEqual, "Fake Master") |
| 260 So(loadB.Currentstep.(string), ShouldEqual, "thi
s is a string") | 260 So(loadB.Currentstep.(string), ShouldEqual, "thi
s is a string") |
| 261 » » » » m, t, err := getMasterJSON(c, "Fake Master") | 261 » » » » m, _, t, err := getMasterJSON(c, "Fake Master") |
| 262 So(err, ShouldBeNil) | 262 So(err, ShouldBeNil) |
| 263 So(t.Unix(), ShouldEqual, 981173106) | 263 So(t.Unix(), ShouldEqual, 981173106) |
| 264 So(m.Name, ShouldEqual, "Fake Master") | 264 So(m.Name, ShouldEqual, "Fake Master") |
| 265 So(m.Project.Title, ShouldEqual, "some title") | 265 So(m.Project.Title, ShouldEqual, "some title") |
| 266 So(m.Slaves["testslave"].Name, ShouldEqual, "tes
tslave") | 266 So(m.Slaves["testslave"].Name, ShouldEqual, "tes
tslave") |
| 267 So(len(m.Slaves["testslave"].Runningbuilds), Sho
uldEqual, 0) | 267 So(len(m.Slaves["testslave"].Runningbuilds), Sho
uldEqual, 0) |
| 268 So(len(m.Slaves["testslave"].RunningbuildsMap),
ShouldEqual, 1) | 268 So(len(m.Slaves["testslave"].RunningbuildsMap),
ShouldEqual, 1) |
| 269 So(m.Slaves["testslave"].RunningbuildsMap["Fake
buildername"][0], | 269 So(m.Slaves["testslave"].RunningbuildsMap["Fake
buildername"][0], |
| 270 ShouldEqual, 2222) | 270 ShouldEqual, 2222) |
| 271 }) | 271 }) |
| 272 | 272 |
| 273 Convey("And a new master overwrites", func() { | 273 Convey("And a new master overwrites", func() { |
| 274 c, _ = testclock.UseTime(c, fakeTime.Add(time.Du
ration(1*time.Second))) | 274 c, _ = testclock.UseTime(c, fakeTime.Add(time.Du
ration(1*time.Second))) |
| 275 ms.Project.Title = "some other title" | 275 ms.Project.Title = "some other title" |
| 276 h = httptest.NewRecorder() | 276 h = httptest.NewRecorder() |
| 277 r := &http.Request{ | 277 r := &http.Request{ |
| 278 Body: newCombinedPsBody([]*buildbotBuild
{b}, &ms, false)} | 278 Body: newCombinedPsBody([]*buildbotBuild
{b}, &ms, false)} |
| 279 p = httprouter.Params{} | 279 p = httprouter.Params{} |
| 280 PubSubHandler(&router.Context{ | 280 PubSubHandler(&router.Context{ |
| 281 Context: c, | 281 Context: c, |
| 282 Writer: h, | 282 Writer: h, |
| 283 Request: r, | 283 Request: r, |
| 284 Params: p, | 284 Params: p, |
| 285 }) | 285 }) |
| 286 So(h.Code, ShouldEqual, 200) | 286 So(h.Code, ShouldEqual, 200) |
| 287 » » » » m, t, err := getMasterJSON(c, "Fake Master") | 287 » » » » m, _, t, err := getMasterJSON(c, "Fake Master") |
| 288 So(err, ShouldBeNil) | 288 So(err, ShouldBeNil) |
| 289 So(m.Project.Title, ShouldEqual, "some other tit
le") | 289 So(m.Project.Title, ShouldEqual, "some other tit
le") |
| 290 So(t.Unix(), ShouldEqual, 981173107) | 290 So(t.Unix(), ShouldEqual, 981173107) |
| 291 So(m.Name, ShouldEqual, "Fake Master") | 291 So(m.Name, ShouldEqual, "Fake Master") |
| 292 }) | 292 }) |
| 293 Convey("And a new build overwrites", func() { | 293 Convey("And a new build overwrites", func() { |
| 294 b.Times = buildbotTimesFinished(123.0, 124.0) | 294 b.Times = buildbotTimesFinished(123.0, 124.0) |
| 295 h = httptest.NewRecorder() | 295 h = httptest.NewRecorder() |
| 296 r = &http.Request{ | 296 r = &http.Request{ |
| 297 Body: newCombinedPsBody([]*buildbotBuild
{b}, &ms, false), | 297 Body: newCombinedPsBody([]*buildbotBuild
{b}, &ms, false), |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 loadB := &buildbotBuild{ | 471 loadB := &buildbotBuild{ |
| 472 Master: "Fake Master", | 472 Master: "Fake Master", |
| 473 Buildername: "Fake buildername", | 473 Buildername: "Fake buildername", |
| 474 Number: 1234, | 474 Number: 1234, |
| 475 } | 475 } |
| 476 err = ds.Get(c, loadB) | 476 err = ds.Get(c, loadB) |
| 477 So(err, ShouldBeNil) | 477 So(err, ShouldBeNil) |
| 478 So(loadB.Master, ShouldEqual, "Fake Master") | 478 So(loadB.Master, ShouldEqual, "Fake Master") |
| 479 So(loadB.Internal, ShouldEqual, true) | 479 So(loadB.Internal, ShouldEqual, true) |
| 480 So(loadB.Currentstep.(string), ShouldEqual, "thi
s is a string") | 480 So(loadB.Currentstep.(string), ShouldEqual, "thi
s is a string") |
| 481 » » » » m, t, err := getMasterJSON(c, "Fake Master") | 481 » » » » m, _, t, err := getMasterJSON(c, "Fake Master") |
| 482 So(err, ShouldBeNil) | 482 So(err, ShouldBeNil) |
| 483 So(t.Unix(), ShouldEqual, 981173106) | 483 So(t.Unix(), ShouldEqual, 981173106) |
| 484 So(m.Name, ShouldEqual, "Fake Master") | 484 So(m.Name, ShouldEqual, "Fake Master") |
| 485 So(m.Project.Title, ShouldEqual, "some title") | 485 So(m.Project.Title, ShouldEqual, "some title") |
| 486 So(m.Slaves["testslave"].Name, ShouldEqual, "tes
tslave") | 486 So(m.Slaves["testslave"].Name, ShouldEqual, "tes
tslave") |
| 487 So(len(m.Slaves["testslave"].Runningbuilds), Sho
uldEqual, 0) | 487 So(len(m.Slaves["testslave"].Runningbuilds), Sho
uldEqual, 0) |
| 488 So(len(m.Slaves["testslave"].RunningbuildsMap),
ShouldEqual, 1) | 488 So(len(m.Slaves["testslave"].RunningbuildsMap),
ShouldEqual, 1) |
| 489 So(m.Slaves["testslave"].RunningbuildsMap["Fake
buildername"][0], | 489 So(m.Slaves["testslave"].RunningbuildsMap["Fake
buildername"][0], |
| 490 ShouldEqual, 2222) | 490 ShouldEqual, 2222) |
| 491 }) | 491 }) |
| 492 }) | 492 }) |
| 493 }) | 493 }) |
| 494 } | 494 } |
| OLD | NEW |