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

Side by Side Diff: appengine/cmd/milo/buildbucket/builder_test.go

Issue 2134673003: milo: buildbucket builer view (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebased and regenerated expectations Created 4 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
« no previous file with comments | « appengine/cmd/milo/buildbucket/builder.go ('k') | appengine/cmd/milo/buildbucket/common.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package buildbucket
6
7 import (
8 "encoding/json"
9 "flag"
10 "fmt"
11 "io/ioutil"
12 "os"
13 "path/filepath"
14 "testing"
15 "time"
16
17 "github.com/luci/luci-go/common/clock/testclock"
18 "golang.org/x/net/context"
19
20 . "github.com/smartystreets/goconvey/convey"
21 )
22
23 var generate = flag.Bool("test.generate", false, "Generate expectations instead of running tests.")
24
25 func TestBuilder(t *testing.T) {
26 t.Parallel()
27
28 testCases := []struct{ bucket, builder string }{
29 {"master.tryserver.infra", "InfraPresubmit"},
30 {"master.tryserver.infra", "InfraPresubmit(Swarming)"},
31 }
32
33 Convey("Builder", t, func() {
34 c := context.Background()
35 c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
36
37 for _, tc := range testCases {
38 tc := tc
39 Convey(fmt.Sprintf("%s:%s", tc.bucket, tc.builder), func () {
40 expectationFilePath := filepath.Join("expectatio ns", tc.bucket, tc.builder+".json")
41 err := os.MkdirAll(filepath.Dir(expectationFileP ath), 0777)
42 So(err, ShouldBeNil)
43
44 actual, err := builderImpl(c, "debug", tc.bucket , tc.builder, 0)
45 So(err, ShouldBeNil)
46 actualJSON, err := json.MarshalIndent(actual, "" , " ")
47 So(err, ShouldBeNil)
48
49 if *generate {
50 err := ioutil.WriteFile(expectationFileP ath, actualJSON, 0777)
51 So(err, ShouldBeNil)
52 } else {
53 expectedJSON, err := ioutil.ReadFile(exp ectationFilePath)
54 So(err, ShouldBeNil)
55 So(string(actualJSON), ShouldEqual, stri ng(expectedJSON))
56 }
57 })
58 }
59 })
60 }
OLDNEW
« no previous file with comments | « appengine/cmd/milo/buildbucket/builder.go ('k') | appengine/cmd/milo/buildbucket/common.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698