| OLD | NEW |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 actualBuild, err := json.MarshalIndent(actualContents, "", " ") | 42 actualBuild, err := json.MarshalIndent(actualContents, "", " ") |
| 43 return ShouldEqual(string(actualBuild), string(refBuild)) | 43 return ShouldEqual(string(actualBuild), string(refBuild)) |
| 44 | 44 |
| 45 } | 45 } |
| 46 | 46 |
| 47 func TestBuild(t *testing.T) { | 47 func TestBuild(t *testing.T) { |
| 48 t.Parallel() | 48 t.Parallel() |
| 49 | 49 |
| 50 if *generate { | 50 if *generate { |
| 51 c := context.Background() | 51 c := context.Background() |
| 52 // This is one hour after the start timestamp in the sample test
data. |
| 52 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)) |
| 53 c = memory.UseWithAppID(c, "dev~luci-milo") | 54 c = memory.UseWithAppID(c, "dev~luci-milo") |
| 54 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs)) | 55 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs)) |
| 55 c = auth.WithState(c, &authtest.FakeState{ | 56 c = auth.WithState(c, &authtest.FakeState{ |
| 56 Identity: "user:alicebob@google.com", | 57 Identity: "user:alicebob@google.com", |
| 57 IdentityGroups: []string{"all", "googlers"}, | 58 IdentityGroups: []string{"all", "googlers"}, |
| 58 }) | 59 }) |
| 59 | 60 |
| 60 for _, tc := range getTestCases() { | 61 for _, tc := range getTestCases() { |
| 61 bl := buildLoader{ | 62 bl := buildLoader{ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 77 err = ioutil.WriteFile(filename, []byte(buildJSON), 0644
) | 78 err = ioutil.WriteFile(filename, []byte(buildJSON), 0644
) |
| 78 if err != nil { | 79 if err != nil { |
| 79 panic(fmt.Errorf("Encountered error while trying
to write to %s: %s", filename, err)) | 80 panic(fmt.Errorf("Encountered error while trying
to write to %s: %s", filename, err)) |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 return | 83 return |
| 83 } | 84 } |
| 84 | 85 |
| 85 Convey(`A test Environment`, t, func() { | 86 Convey(`A test Environment`, t, func() { |
| 86 c := context.Background() | 87 c := context.Background() |
| 88 // This is one hour after the start timestamp in the sample test
data. |
| 87 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)) |
| 88 c = memory.UseWithAppID(c, "dev~luci-milo") | 90 c = memory.UseWithAppID(c, "dev~luci-milo") |
| 89 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs)) | 91 c = testconfig.WithCommonClient(c, memcfg.New(aclConfgs)) |
| 90 c = auth.WithState(c, &authtest.FakeState{ | 92 c = auth.WithState(c, &authtest.FakeState{ |
| 91 Identity: "user:alicebob@google.com", | 93 Identity: "user:alicebob@google.com", |
| 92 IdentityGroups: []string{"all", "googlers"}, | 94 IdentityGroups: []string{"all", "googlers"}, |
| 93 }) | 95 }) |
| 94 | 96 |
| 95 for _, tc := range getTestCases() { | 97 for _, tc := range getTestCases() { |
| 96 Convey(fmt.Sprintf("Test Case: %s", tc.name), func() { | 98 Convey(fmt.Sprintf("Test Case: %s", tc.name), func() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 111 }) | 113 }) |
| 112 } | 114 } |
| 113 | 115 |
| 114 build, err := bl.swarmingBuildImpl(c, svc, "foo"
, tc.name) | 116 build, err := bl.swarmingBuildImpl(c, svc, "foo"
, tc.name) |
| 115 So(err, ShouldBeNil) | 117 So(err, ShouldBeNil) |
| 116 So(build, shouldMatchExpectationsFor, tc.name+".
json") | 118 So(build, shouldMatchExpectationsFor, tc.name+".
json") |
| 117 }) | 119 }) |
| 118 } | 120 } |
| 119 }) | 121 }) |
| 120 } | 122 } |
| OLD | NEW |