| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. | 1 // Copyright 2017 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 t.Parallel() | 152 t.Parallel() |
| 153 | 153 |
| 154 Convey("Scheduler GetInvocations API works", t, func() { | 154 Convey("Scheduler GetInvocations API works", t, func() { |
| 155 ctx := gaetesting.TestingContext() | 155 ctx := gaetesting.TestingContext() |
| 156 fakeEng, catalog := newTestEngine() | 156 fakeEng, catalog := newTestEngine() |
| 157 _, err := registerUrlFetcher(catalog) | 157 _, err := registerUrlFetcher(catalog) |
| 158 So(err, ShouldBeNil) | 158 So(err, ShouldBeNil) |
| 159 ss := SchedulerServer{fakeEng, catalog} | 159 ss := SchedulerServer{fakeEng, catalog} |
| 160 | 160 |
| 161 Convey("Job not found", func() { | 161 Convey("Job not found", func() { |
| 162 » » » fakeEng.getVisibleJob = func(JobID string) (*engine.Job,
error) { return nil, nil } | 162 » » » fakeEng.listVisibleInvocations = func(int, string) ([]*e
ngine.Invocation, string, error) { |
| 163 » » » » return nil, "", engine.ErrNoSuchJob |
| 164 » » » } |
| 163 _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ | 165 _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ |
| 164 JobRef: &scheduler.JobRef{Project: "not", Job: "
exists"}, | 166 JobRef: &scheduler.JobRef{Project: "not", Job: "
exists"}, |
| 165 }) | 167 }) |
| 166 s, ok := status.FromError(err) | 168 s, ok := status.FromError(err) |
| 167 So(ok, ShouldBeTrue) | 169 So(ok, ShouldBeTrue) |
| 168 So(s.Code(), ShouldEqual, codes.NotFound) | 170 So(s.Code(), ShouldEqual, codes.NotFound) |
| 169 }) | 171 }) |
| 170 | 172 |
| 171 Convey("DS error", func() { | 173 Convey("DS error", func() { |
| 172 » » » fakeEng.getVisibleJob = func(JobID string) (*engine.Job,
error) { return nil, fmt.Errorf("ds error") } | 174 » » » fakeEng.listVisibleInvocations = func(int, string) ([]*e
ngine.Invocation, string, error) { |
| 175 » » » » return nil, "", fmt.Errorf("ds error") |
| 176 » » » } |
| 173 _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ | 177 _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ |
| 174 JobRef: &scheduler.JobRef{Project: "proj", Job:
"job"}, | 178 JobRef: &scheduler.JobRef{Project: "proj", Job:
"job"}, |
| 175 }) | 179 }) |
| 176 s, ok := status.FromError(err) | 180 s, ok := status.FromError(err) |
| 177 So(ok, ShouldBeTrue) | 181 So(ok, ShouldBeTrue) |
| 178 So(s.Code(), ShouldEqual, codes.Internal) | 182 So(s.Code(), ShouldEqual, codes.Internal) |
| 179 }) | 183 }) |
| 180 | 184 |
| 181 fakeEng.getVisibleJob = func(JobID string) (*engine.Job, error)
{ | 185 fakeEng.getVisibleJob = func(JobID string) (*engine.Job, error)
{ |
| 182 return &engine.Job{JobID: "proj/job", ProjectID: "proj"}
, nil | 186 return &engine.Job{JobID: "proj/job", ProjectID: "proj"}
, nil |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 panic("not implemented") | 437 panic("not implemented") |
| 434 } | 438 } |
| 435 | 439 |
| 436 func (f *fakeEngine) TriggerInvocation(c context.Context, jobID string) (int64,
error) { | 440 func (f *fakeEngine) TriggerInvocation(c context.Context, jobID string) (int64,
error) { |
| 437 panic("not implemented") | 441 panic("not implemented") |
| 438 } | 442 } |
| 439 | 443 |
| 440 func (f *fakeEngine) InternalAPI() engine.EngineInternal { | 444 func (f *fakeEngine) InternalAPI() engine.EngineInternal { |
| 441 panic("not implemented") | 445 panic("not implemented") |
| 442 } | 446 } |
| OLD | NEW |