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

Side by Side Diff: milo/appengine/job_source/swarming/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 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 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 swarming 5 package swarming
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 c := context.Background() 51 c := context.Background()
52 // This is one hour after the start timestamp in the sample test data. 52 // This is one hour after the start timestamp in the sample test data.
53 c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC)) 53 c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
54 c = memory.UseWithAppID(c, "dev~luci-milo") 54 c = memory.UseWithAppID(c, "dev~luci-milo")
55 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs)) 55 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs))
56 c = auth.WithState(c, &authtest.FakeState{ 56 c = auth.WithState(c, &authtest.FakeState{
57 Identity: "user:alicebob@google.com", 57 Identity: "user:alicebob@google.com",
58 IdentityGroups: []string{"all", "googlers"}, 58 IdentityGroups: []string{"all", "googlers"},
59 }) 59 })
60 60
61 » » for _, tc := range getTestCases() { 61 » » for _, tc := range getTestCases(".") {
62 bl := buildLoader{ 62 bl := buildLoader{
63 logDogClientFunc: logDogClientFunc(tc), 63 logDogClientFunc: logDogClientFunc(tc),
64 } 64 }
65 svc := debugSwarmingService{tc} 65 svc := debugSwarmingService{tc}
66 66
67 fmt.Printf("Generating expectations for %s\n", tc) 67 fmt.Printf("Generating expectations for %s\n", tc)
68 68
69 build, err := bl.swarmingBuildImpl(c, svc, "foo", tc.nam e) 69 build, err := bl.swarmingBuildImpl(c, svc, "foo", tc.nam e)
70 if err != nil { 70 if err != nil {
71 panic(fmt.Errorf("Could not run swarmingBuildImp l for %s: %s", tc, err)) 71 panic(fmt.Errorf("Could not run swarmingBuildImp l for %s: %s", tc, err))
(...skipping 15 matching lines...) Expand all
87 c := context.Background() 87 c := context.Background()
88 // This is one hour after the start timestamp in the sample test data. 88 // This is one hour after the start timestamp in the sample test data.
89 c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC)) 89 c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
90 c = memory.UseWithAppID(c, "dev~luci-milo") 90 c = memory.UseWithAppID(c, "dev~luci-milo")
91 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs)) 91 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs))
92 c = auth.WithState(c, &authtest.FakeState{ 92 c = auth.WithState(c, &authtest.FakeState{
93 Identity: "user:alicebob@google.com", 93 Identity: "user:alicebob@google.com",
94 IdentityGroups: []string{"all", "googlers"}, 94 IdentityGroups: []string{"all", "googlers"},
95 }) 95 })
96 96
97 » » for _, tc := range getTestCases() { 97 » » for _, tc := range getTestCases(".") {
98 Convey(fmt.Sprintf("Test Case: %s", tc.name), func() { 98 Convey(fmt.Sprintf("Test Case: %s", tc.name), func() {
99 bl := buildLoader{ 99 bl := buildLoader{
100 logDogClientFunc: logDogClientFunc(tc), 100 logDogClientFunc: logDogClientFunc(tc),
101 } 101 }
102 svc := debugSwarmingService{tc} 102 svc := debugSwarmingService{tc}
103 103
104 // Special case: The build-internal test case to check that ACLs should fail. 104 // Special case: The build-internal test case to check that ACLs should fail.
105 if tc.name == "build-internal" { 105 if tc.name == "build-internal" {
106 Convey("Should fail", func() { 106 Convey("Should fail", func() {
107 c := auth.WithState(c, &authtest .FakeState{ 107 c := auth.WithState(c, &authtest .FakeState{
108 Identity: identity .AnonymousIdentity, 108 Identity: identity .AnonymousIdentity,
109 IdentityGroups: []string {"all"}, 109 IdentityGroups: []string {"all"},
110 }) 110 })
111 _, err := bl.swarmingBuildImpl(c , svc, "foo", tc.name) 111 _, err := bl.swarmingBuildImpl(c , svc, "foo", tc.name)
112 So(err.Error(), ShouldResemble, "Not a Milo Job or access denied") 112 So(err.Error(), ShouldResemble, "Not a Milo Job or access denied")
113 }) 113 })
114 } 114 }
115 115
116 build, err := bl.swarmingBuildImpl(c, svc, "foo" , tc.name) 116 build, err := bl.swarmingBuildImpl(c, svc, "foo" , tc.name)
117 So(err, ShouldBeNil) 117 So(err, ShouldBeNil)
118 So(build, shouldMatchExpectationsFor, tc.name+". json") 118 So(build, shouldMatchExpectationsFor, tc.name+". json")
119 }) 119 })
120 } 120 }
121 }) 121 })
122 } 122 }
OLDNEW
« no previous file with comments | « milo/appengine/job_source/swarming/buildLog_test.go ('k') | milo/appengine/job_source/swarming/buildinfo.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698