| 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" |
| 11 "encoding/json" | 11 "encoding/json" |
| 12 "io" | 12 "io" |
| 13 "io/ioutil" | 13 "io/ioutil" |
| 14 "math/rand" | 14 "math/rand" |
| 15 "net/http" | 15 "net/http" |
| 16 "net/http/httptest" | 16 "net/http/httptest" |
| 17 "testing" | 17 "testing" |
| 18 "time" | 18 "time" |
| 19 | 19 |
| 20 "github.com/luci/gae/impl/memory" | 20 "github.com/luci/gae/impl/memory" |
| 21 ds "github.com/luci/gae/service/datastore" | 21 ds "github.com/luci/gae/service/datastore" |
| 22 "github.com/luci/luci-go/common/clock/testclock" | 22 "github.com/luci/luci-go/common/clock/testclock" |
| 23 memcfg "github.com/luci/luci-go/common/config/impl/memory" | 23 memcfg "github.com/luci/luci-go/common/config/impl/memory" |
| 24 "github.com/luci/luci-go/common/logging/gologger" | 24 "github.com/luci/luci-go/common/logging/gologger" |
| 25 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig
" | 25 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig
" |
| 26 » "github.com/luci/luci-go/milo/appengine/settings" | 26 » "github.com/luci/luci-go/milo/appengine/common" |
| 27 "github.com/luci/luci-go/server/auth" | 27 "github.com/luci/luci-go/server/auth" |
| 28 "github.com/luci/luci-go/server/auth/authtest" | 28 "github.com/luci/luci-go/server/auth/authtest" |
| 29 "github.com/luci/luci-go/server/auth/identity" | 29 "github.com/luci/luci-go/server/auth/identity" |
| 30 "github.com/luci/luci-go/server/router" | 30 "github.com/luci/luci-go/server/router" |
| 31 | 31 |
| 32 "github.com/julienschmidt/httprouter" | 32 "github.com/julienschmidt/httprouter" |
| 33 "golang.org/x/net/context" | 33 "golang.org/x/net/context" |
| 34 | 34 |
| 35 . "github.com/luci/luci-go/common/testing/assertions" | 35 . "github.com/luci/luci-go/common/testing/assertions" |
| 36 . "github.com/smartystreets/goconvey/convey" | 36 . "github.com/smartystreets/goconvey/convey" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 431 } |
| 432 p := httprouter.Params{} | 432 p := httprouter.Params{} |
| 433 PubSubHandler(&router.Context{ | 433 PubSubHandler(&router.Context{ |
| 434 Context: c, | 434 Context: c, |
| 435 Writer: h, | 435 Writer: h, |
| 436 Request: r, | 436 Request: r, |
| 437 Params: p, | 437 Params: p, |
| 438 }) | 438 }) |
| 439 So(h.Code, ShouldEqual, 200) | 439 So(h.Code, ShouldEqual, 200) |
| 440 Convey("And stores correctly", func() { | 440 Convey("And stores correctly", func() { |
| 441 » » » » err := settings.Update(c) | 441 » » » » err := common.Update(c) |
| 442 So(err, ShouldBeNil) | 442 So(err, ShouldBeNil) |
| 443 c = auth.WithState(c, &authtest.FakeState{ | 443 c = auth.WithState(c, &authtest.FakeState{ |
| 444 Identity: "user:alicebob@google.co
m", | 444 Identity: "user:alicebob@google.co
m", |
| 445 IdentityGroups: []string{"googlers", "al
l"}, | 445 IdentityGroups: []string{"googlers", "al
l"}, |
| 446 }) | 446 }) |
| 447 loadB := &buildbotBuild{ | 447 loadB := &buildbotBuild{ |
| 448 Master: "Fake Master", | 448 Master: "Fake Master", |
| 449 Buildername: "Fake buildername", | 449 Buildername: "Fake buildername", |
| 450 Number: 1234, | 450 Number: 1234, |
| 451 } | 451 } |
| 452 err = ds.Get(c, loadB) | 452 err = ds.Get(c, loadB) |
| 453 So(err, ShouldBeNil) | 453 So(err, ShouldBeNil) |
| 454 So(loadB.Master, ShouldEqual, "Fake Master") | 454 So(loadB.Master, ShouldEqual, "Fake Master") |
| 455 So(loadB.Internal, ShouldEqual, true) | 455 So(loadB.Internal, ShouldEqual, true) |
| 456 So(loadB.Currentstep.(string), ShouldEqual, "thi
s is a string") | 456 So(loadB.Currentstep.(string), ShouldEqual, "thi
s is a string") |
| 457 m, t, err := getMasterJSON(c, "Fake Master") | 457 m, t, err := getMasterJSON(c, "Fake Master") |
| 458 So(err, ShouldBeNil) | 458 So(err, ShouldBeNil) |
| 459 So(t.Unix(), ShouldEqual, 981173106) | 459 So(t.Unix(), ShouldEqual, 981173106) |
| 460 So(m.Name, ShouldEqual, "Fake Master") | 460 So(m.Name, ShouldEqual, "Fake Master") |
| 461 So(m.Project.Title, ShouldEqual, "some title") | 461 So(m.Project.Title, ShouldEqual, "some title") |
| 462 So(m.Slaves["testslave"].Name, ShouldEqual, "tes
tslave") | 462 So(m.Slaves["testslave"].Name, ShouldEqual, "tes
tslave") |
| 463 So(len(m.Slaves["testslave"].Runningbuilds), Sho
uldEqual, 0) | 463 So(len(m.Slaves["testslave"].Runningbuilds), Sho
uldEqual, 0) |
| 464 So(len(m.Slaves["testslave"].RunningbuildsMap),
ShouldEqual, 1) | 464 So(len(m.Slaves["testslave"].RunningbuildsMap),
ShouldEqual, 1) |
| 465 So(m.Slaves["testslave"].RunningbuildsMap["Fake
buildername"][0], | 465 So(m.Slaves["testslave"].RunningbuildsMap["Fake
buildername"][0], |
| 466 ShouldEqual, 2222) | 466 ShouldEqual, 2222) |
| 467 }) | 467 }) |
| 468 }) | 468 }) |
| 469 }) | 469 }) |
| 470 } | 470 } |
| OLD | NEW |