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

Unified Diff: milo/appengine/swarming/build_test.go

Issue 2695383002: milo: Enable Swarming LogDog log loading. (Closed)
Patch Set: Comments, fix links. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/appengine/swarming/build.go ('k') | milo/appengine/swarming/buildinfo.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/swarming/build_test.go
diff --git a/milo/appengine/swarming/build_test.go b/milo/appengine/swarming/build_test.go
index 0d81498321e06f327551b337e9eb287b48ad8ba2..b06618e82e9f701d3ffcba6a853ef4e61ab9c872 100644
--- a/milo/appengine/swarming/build_test.go
+++ b/milo/appengine/swarming/build_test.go
@@ -15,6 +15,8 @@ import (
"github.com/luci/luci-go/common/clock/testclock"
+ "github.com/luci/gae/impl/memory"
+
"golang.org/x/net/context"
. "github.com/smartystreets/goconvey/convey"
@@ -38,23 +40,30 @@ func shouldMatchExpectationsFor(actualContents interface{}, expectedFilename ...
}
func TestBuild(t *testing.T) {
- c := context.Background()
- c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
+ t.Parallel()
- var svc debugSwarmingService
if *generate {
+ c := context.Background()
+ c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
+ c = memory.Use(c)
+
for _, tc := range getTestCases() {
+ bl := buildLoader{
+ logDogClientFunc: logDogClientFunc(tc),
+ }
+ svc := debugSwarmingService{tc}
+
fmt.Printf("Generating expectations for %s\n", tc)
- build, err := swarmingBuildImpl(c, svc, "foo", tc)
+ build, err := bl.swarmingBuildImpl(c, svc, "foo", tc.name)
if err != nil {
panic(fmt.Errorf("Could not run swarmingBuildImpl for %s: %s", tc, err))
}
buildJSON, err := json.MarshalIndent(build, "", " ")
if err != nil {
- panic(fmt.Errorf("Could not JSON marshal %s: %s", tc, err))
+ panic(fmt.Errorf("Could not JSON marshal %s: %s", tc.name, err))
}
- filename := filepath.Join("expectations", tc+".json")
+ filename := filepath.Join("expectations", tc.name+".json")
err = ioutil.WriteFile(filename, []byte(buildJSON), 0644)
if err != nil {
panic(fmt.Errorf("Encountered error while trying to write to %s: %s", filename, err))
@@ -64,11 +73,20 @@ func TestBuild(t *testing.T) {
}
Convey(`A test Environment`, t, func() {
+ c := context.Background()
+ c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
+ c = memory.Use(c)
+
for _, tc := range getTestCases() {
- Convey(fmt.Sprintf("Test Case: %s", tc), func() {
- build, err := swarmingBuildImpl(c, svc, "foo", tc)
+ Convey(fmt.Sprintf("Test Case: %s", tc.name), func() {
+ bl := buildLoader{
+ logDogClientFunc: logDogClientFunc(tc),
+ }
+ svc := debugSwarmingService{tc}
+
+ build, err := bl.swarmingBuildImpl(c, svc, "foo", tc.name)
So(err, ShouldBeNil)
- So(build, shouldMatchExpectationsFor, tc+".json")
+ So(build, shouldMatchExpectationsFor, tc.name+".json")
})
}
})
« no previous file with comments | « milo/appengine/swarming/build.go ('k') | milo/appengine/swarming/buildinfo.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698