| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 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 apiservers | 5 package apiservers |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "testing" | 8 "testing" |
| 9 | 9 |
| 10 "golang.org/x/net/context" | 10 "golang.org/x/net/context" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 fakeEng.getAllJobs = func() ([]*engine.Job, error) { ret
urn []*engine.Job{}, nil } | 40 fakeEng.getAllJobs = func() ([]*engine.Job, error) { ret
urn []*engine.Job{}, nil } |
| 41 reply, err := ss.GetJobs(ctx, nil) | 41 reply, err := ss.GetJobs(ctx, nil) |
| 42 So(err, ShouldBeNil) | 42 So(err, ShouldBeNil) |
| 43 So(len(reply.GetJobs()), ShouldEqual, 0) | 43 So(len(reply.GetJobs()), ShouldEqual, 0) |
| 44 }) | 44 }) |
| 45 | 45 |
| 46 Convey("All Projects", func() { | 46 Convey("All Projects", func() { |
| 47 fakeEng.getAllJobs = func() ([]*engine.Job, error) { | 47 fakeEng.getAllJobs = func() ([]*engine.Job, error) { |
| 48 return []*engine.Job{ | 48 return []*engine.Job{ |
| 49 { | 49 { |
| 50 » » » » » » JobID: "foo", | 50 » » » » » » JobID: "bar/foo", |
| 51 ProjectID: "bar", | 51 ProjectID: "bar", |
| 52 Schedule: "0 * * * * * *", | 52 Schedule: "0 * * * * * *", |
| 53 State: engine.JobState{State
: engine.JobStateRunning}, | 53 State: engine.JobState{State
: engine.JobStateRunning}, |
| 54 Task: taskBlob, | 54 Task: taskBlob, |
| 55 }, | 55 }, |
| 56 { | 56 { |
| 57 » » » » » » JobID: "faz", | 57 » » » » » » JobID: "baz/faz", |
| 58 Paused: true, | 58 Paused: true, |
| 59 ProjectID: "baz", | 59 ProjectID: "baz", |
| 60 Schedule: "with 1m interval", | 60 Schedule: "with 1m interval", |
| 61 State: engine.JobState{State
: engine.JobStateSuspended}, | 61 State: engine.JobState{State
: engine.JobStateSuspended}, |
| 62 Task: taskBlob, | 62 Task: taskBlob, |
| 63 }, | 63 }, |
| 64 }, nil | 64 }, nil |
| 65 } | 65 } |
| 66 reply, err := ss.GetJobs(ctx, nil) | 66 reply, err := ss.GetJobs(ctx, nil) |
| 67 So(err, ShouldBeNil) | 67 So(err, ShouldBeNil) |
| 68 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ | 68 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ |
| 69 { | 69 { |
| 70 » » » » » Id: "foo", | 70 » » » » » Name: "foo", |
| 71 Project: "bar", | 71 Project: "bar", |
| 72 Schedule: "0 * * * * * *", | 72 Schedule: "0 * * * * * *", |
| 73 State: &scheduler.JobState{UiStatus:
"RUNNING"}, | 73 State: &scheduler.JobState{UiStatus:
"RUNNING"}, |
| 74 }, | 74 }, |
| 75 { | 75 { |
| 76 » » » » » Id: "faz", | 76 » » » » » Name: "faz", |
| 77 Project: "baz", | 77 Project: "baz", |
| 78 Schedule: "with 1m interval", | 78 Schedule: "with 1m interval", |
| 79 State: &scheduler.JobState{UiStatus:
"PAUSED"}, | 79 State: &scheduler.JobState{UiStatus:
"PAUSED"}, |
| 80 }, | 80 }, |
| 81 }) | 81 }) |
| 82 }) | 82 }) |
| 83 | 83 |
| 84 Convey("One Project", func() { | 84 Convey("One Project", func() { |
| 85 fakeEng.getProjectJobs = func(projectID string) ([]*engi
ne.Job, error) { | 85 fakeEng.getProjectJobs = func(projectID string) ([]*engi
ne.Job, error) { |
| 86 So(projectID, ShouldEqual, "bar") | 86 So(projectID, ShouldEqual, "bar") |
| 87 return []*engine.Job{ | 87 return []*engine.Job{ |
| 88 { | 88 { |
| 89 » » » » » » JobID: "foo", | 89 » » » » » » JobID: "bar/foo", |
| 90 ProjectID: "bar", | 90 ProjectID: "bar", |
| 91 Schedule: "0 * * * * * *", | 91 Schedule: "0 * * * * * *", |
| 92 State: engine.JobState{State
: engine.JobStateRunning}, | 92 State: engine.JobState{State
: engine.JobStateRunning}, |
| 93 Task: taskBlob, | 93 Task: taskBlob, |
| 94 }, | 94 }, |
| 95 }, nil | 95 }, nil |
| 96 } | 96 } |
| 97 reply, err := ss.GetJobs(ctx, &scheduler.JobsRequest{Pro
ject: "bar"}) | 97 reply, err := ss.GetJobs(ctx, &scheduler.JobsRequest{Pro
ject: "bar"}) |
| 98 So(err, ShouldBeNil) | 98 So(err, ShouldBeNil) |
| 99 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ | 99 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ |
| 100 { | 100 { |
| 101 » » » » » Id: "foo", | 101 » » » » » Name: "foo", |
| 102 Project: "bar", | 102 Project: "bar", |
| 103 Schedule: "0 * * * * * *", | 103 Schedule: "0 * * * * * *", |
| 104 State: &scheduler.JobState{UiStatus:
"RUNNING"}, | 104 State: &scheduler.JobState{UiStatus:
"RUNNING"}, |
| 105 }, | 105 }, |
| 106 }) | 106 }) |
| 107 }) | 107 }) |
| 108 }) | 108 }) |
| 109 } | 109 } |
| 110 | 110 |
| 111 //// | 111 //// |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 panic("not implemented") | 180 panic("not implemented") |
| 181 } | 181 } |
| 182 | 182 |
| 183 func (f *fakeEngine) AbortInvocation(c context.Context, jobID string, invID int6
4, who identity.Identity) error { | 183 func (f *fakeEngine) AbortInvocation(c context.Context, jobID string, invID int6
4, who identity.Identity) error { |
| 184 panic("not implemented") | 184 panic("not implemented") |
| 185 } | 185 } |
| 186 | 186 |
| 187 func (f *fakeEngine) AbortJob(c context.Context, jobID string, who identity.Iden
tity) error { | 187 func (f *fakeEngine) AbortJob(c context.Context, jobID string, who identity.Iden
tity) error { |
| 188 panic("not implemented") | 188 panic("not implemented") |
| 189 } | 189 } |
| OLD | NEW |