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

Side by Side Diff: milo/buildsource/buildbot/builder_test.go

Issue 2977863002: [milo] Refactor all html knowledge out of backends. (Closed)
Patch Set: seems to work :) Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The LUCI Authors. 1 // Copyright 2017 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 putDSMasterJSON(c, &buildbotMaster{ 60 putDSMasterJSON(c, &buildbotMaster{
61 Name: "fake", 61 Name: "fake",
62 Builders: map[string]*buildbotBuilder{"fake": {}}, 62 Builders: map[string]*buildbotBuilder{"fake": {}},
63 }, false) 63 }, false)
64 datastore.GetTestable(c).Consistent(true) 64 datastore.GetTestable(c).Consistent(true)
65 datastore.GetTestable(c).AutoIndex(true) 65 datastore.GetTestable(c).AutoIndex(true)
66 datastore.GetTestable(c).CatchupIndexes() 66 datastore.GetTestable(c).CatchupIndexes()
67 Convey(`A test Environment`, t, func() { 67 Convey(`A test Environment`, t, func() {
68 68
69 Convey(`Invalid builder`, func() { 69 Convey(`Invalid builder`, func() {
70 » » » _, err := builderImpl(c, "fake", "not real builder", 2, "") 70 » » » _, err := GetBuilder(c, "fake", "not real builder", 2, n il)
71 So(err.Error(), ShouldResemble, "Cannot find builder \"n ot real builder\" in master \"fake\".\nAvailable builders: \nfake") 71 So(err.Error(), ShouldResemble, "Cannot find builder \"n ot real builder\" in master \"fake\".\nAvailable builders: \nfake")
72 }) 72 })
73 Convey(`Basic 3 build builder`, func() { 73 Convey(`Basic 3 build builder`, func() {
74 Convey(`Fetch 2`, func() { 74 Convey(`Fetch 2`, func() {
75 » » » » response, err := builderImpl(c, "fake", "fake", 2, "") 75 » » » » response, err := GetBuilder(c, "fake", "fake", 2 , nil)
76 So(err, ShouldBeNil) 76 So(err, ShouldBeNil)
77 So(len(response.FinishedBuilds), ShouldEqual, 2) 77 So(len(response.FinishedBuilds), ShouldEqual, 2)
78 So(response.NextCursor, ShouldNotEqual, "") 78 So(response.NextCursor, ShouldNotEqual, "")
79 So(response.PrevCursor, ShouldEqual, "") 79 So(response.PrevCursor, ShouldEqual, "")
80 So(response.FinishedBuilds[0].Link.Label, Should Equal, "#10") 80 So(response.FinishedBuilds[0].Link.Label, Should Equal, "#10")
81 So(response.FinishedBuilds[0].Text, ShouldResemb le, []string{"failed stuff"}) 81 So(response.FinishedBuilds[0].Text, ShouldResemb le, []string{"failed stuff"})
82
83 cursor, err := datastore.DecodeCursor(c, respons e.NextCursor)
84 So(err, ShouldBeNil)
85
82 Convey(`Fetch another 2`, func() { 86 Convey(`Fetch another 2`, func() {
83 » » » » » response2, err := builderImpl(c, "fake", "fake", 2, response.NextCursor) 87 » » » » » response2, err := GetBuilder(c, "fake", "fake", 2, cursor)
84 So(err, ShouldBeNil) 88 So(err, ShouldBeNil)
85 So(len(response2.FinishedBuilds), Should Equal, 2) 89 So(len(response2.FinishedBuilds), Should Equal, 2)
86 So(response2.PrevCursor, ShouldEqual, "E MPTY") 90 So(response2.PrevCursor, ShouldEqual, "E MPTY")
91
92 cursor, err := datastore.DecodeCursor(c, response2.NextCursor)
93 So(err, ShouldBeNil)
94
87 Convey(`Fetch another 2`, func() { 95 Convey(`Fetch another 2`, func() {
88 » » » » » » response3, err := builderImpl(c, "fake", "fake", 2, response2.NextCursor) 96 » » » » » » response3, err := GetBuilder(c, "fake", "fake", 2, cursor)
89 So(err, ShouldBeNil) 97 So(err, ShouldBeNil)
90 So(len(response3.FinishedBuilds) , ShouldEqual, 2) 98 So(len(response3.FinishedBuilds) , ShouldEqual, 2)
91 So(response3.PrevCursor, ShouldN otEqual, "") 99 So(response3.PrevCursor, ShouldN otEqual, "")
92 So(response3.PrevCursor, ShouldN otEqual, "EMPTY") 100 So(response3.PrevCursor, ShouldN otEqual, "EMPTY")
101
102 cursor, err := datastore.DecodeC ursor(c, response3.NextCursor)
103 So(err, ShouldBeNil)
104
93 Convey(`Fetch the rest`, func() { 105 Convey(`Fetch the rest`, func() {
94 » » » » » » » response4, err := builde rImpl(c, "fake", "fake", 20, response3.NextCursor) 106 » » » » » » » response4, err := GetBui lder(c, "fake", "fake", 20, cursor)
95 So(err, ShouldBeNil) 107 So(err, ShouldBeNil)
96 So(len(response4.Finishe dBuilds), ShouldEqual, 4) 108 So(len(response4.Finishe dBuilds), ShouldEqual, 4)
97 }) 109 })
98 }) 110 })
99 }) 111 })
100 }) 112 })
101 }) 113 })
102 }) 114 })
103 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698