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

Side by Side Diff: milo/appengine/job_source/buildbot/build_test.go

Issue 2944983003: [milo] {buildbucket,buildbot,swarming,logdog} -> backends/*. (Closed)
Patch Set: fix the tests Created 3 years, 6 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 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 "encoding/json" 8 "encoding/json"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 } 45 }
46 46
47 func TestBuild(t *testing.T) { 47 func TestBuild(t *testing.T) {
48 c := memory.UseWithAppID(context.Background(), "dev~luci-milo") 48 c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
49 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) 49 c, _ = testclock.UseTime(c, testclock.TestTimeUTC)
50 50
51 if *generate { 51 if *generate {
52 for _, tc := range TestCases { 52 for _, tc := range TestCases {
53 fmt.Printf("Generating expectations for %s/%s\n", tc.Bui lder, tc.Build) 53 fmt.Printf("Generating expectations for %s/%s\n", tc.Bui lder, tc.Build)
54 » » » build, err := Build(c, "debug", tc.Builder, tc.Build) 54 » » » build, err := DebugBuild(c, ".", tc.Builder, tc.Build)
55 if err != nil { 55 if err != nil {
56 panic(fmt.Errorf("Could not run build() for %s/% s: %s", tc.Builder, tc.Build, err)) 56 panic(fmt.Errorf("Could not run build() for %s/% s: %s", tc.Builder, tc.Build, err))
57 } 57 }
58 buildJSON, err := json.MarshalIndent(build, "", " ") 58 buildJSON, err := json.MarshalIndent(build, "", " ")
59 if err != nil { 59 if err != nil {
60 panic(fmt.Errorf("Could not JSON marshal %s/%s: %s", tc.Builder, tc.Build, err)) 60 panic(fmt.Errorf("Could not JSON marshal %s/%s: %s", tc.Builder, tc.Build, err))
61 } 61 }
62 fname := fmt.Sprintf("%s.%d.build.json", tc.Builder, tc. Build) 62 fname := fmt.Sprintf("%s.%d.build.json", tc.Builder, tc. Build)
63 fpath := path.Join("expectations", fname) 63 fpath := path.Join("expectations", fname)
64 err = ioutil.WriteFile(fpath, []byte(buildJSON), 0644) 64 err = ioutil.WriteFile(fpath, []byte(buildJSON), 0644)
65 if err != nil { 65 if err != nil {
66 panic(fmt.Errorf("Encountered error while trying to write to %s: %s", fpath, err)) 66 panic(fmt.Errorf("Encountered error while trying to write to %s: %s", fpath, err))
67 } 67 }
68 } 68 }
69 return 69 return
70 } 70 }
71 71
72 Convey(`A test Environment`, t, func() { 72 Convey(`A test Environment`, t, func() {
73 c = testconfig.WithCommonClient(c, memcfg.New(bbAclConfigs)) 73 c = testconfig.WithCommonClient(c, memcfg.New(bbAclConfigs))
74 c = auth.WithState(c, &authtest.FakeState{ 74 c = auth.WithState(c, &authtest.FakeState{
75 Identity: identity.AnonymousIdentity, 75 Identity: identity.AnonymousIdentity,
76 IdentityGroups: []string{"all"}, 76 IdentityGroups: []string{"all"},
77 }) 77 })
78 78
79 for _, tc := range TestCases { 79 for _, tc := range TestCases {
80 Convey(fmt.Sprintf("Test Case: %s/%s", tc.Builder, tc.Bu ild), func() { 80 Convey(fmt.Sprintf("Test Case: %s/%s", tc.Builder, tc.Bu ild), func() {
81 » » » » build, err := Build(c, "debug", tc.Builder, tc.B uild) 81 » » » » build, err := DebugBuild(c, ".", tc.Builder, tc. Build)
82 So(err, ShouldBeNil) 82 So(err, ShouldBeNil)
83 fname := fmt.Sprintf("%s.%d.build.json", tc.Buil der, tc.Build) 83 fname := fmt.Sprintf("%s.%d.build.json", tc.Buil der, tc.Build)
84 So(build, shouldMatchExpectationsFor, fname) 84 So(build, shouldMatchExpectationsFor, fname)
85 }) 85 })
86 } 86 }
87 87
88 Convey(`Disallow anonomyous users from accessing internal builds `, func() { 88 Convey(`Disallow anonomyous users from accessing internal builds `, func() {
89 ds.Put(c, &buildbotBuild{ 89 ds.Put(c, &buildbotBuild{
90 Master: "fake", 90 Master: "fake",
91 Buildername: "fake", 91 Buildername: "fake",
(...skipping 12 matching lines...) Expand all
104 public_subscription: "projects/luci-milo/subscriptions/buildbot-public" 104 public_subscription: "projects/luci-milo/subscriptions/buildbot-public"
105 internal_subscription: "projects/luci-milo/subscriptions/buildbot-privat e" 105 internal_subscription: "projects/luci-milo/subscriptions/buildbot-privat e"
106 } 106 }
107 ` 107 `
108 108
109 var bbAclConfigs = map[string]memcfg.ConfigSet{ 109 var bbAclConfigs = map[string]memcfg.ConfigSet{
110 "services/luci-milo": { 110 "services/luci-milo": {
111 "settings.cfg": internalConfig, 111 "settings.cfg": internalConfig,
112 }, 112 },
113 } 113 }
OLDNEW
« no previous file with comments | « milo/appengine/job_source/buildbot/build.go ('k') | milo/appengine/job_source/buildbot/builder.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698