| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 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 29 matching lines...) Expand all Loading... |
| 40 Command: []string{"echo", "Hi!"}, | 40 Command: []string{"echo", "Hi!"}, |
| 41 Env: []string{"A=B", "C=D"}, | 41 Env: []string{"A=B", "C=D"}, |
| 42 Dimensions: []string{"OS:Linux"}, | 42 Dimensions: []string{"OS:Linux"}, |
| 43 Tags: []string{"a:b", "c:d"}, | 43 Tags: []string{"a:b", "c:d"}, |
| 44 Priority: 50, | 44 Priority: 50, |
| 45 }), ShouldBeNil) | 45 }), ShouldBeNil) |
| 46 }) | 46 }) |
| 47 | 47 |
| 48 Convey("ValidateProtoMessage passes good minimal msg", t, func() { | 48 Convey("ValidateProtoMessage passes good minimal msg", t, func() { |
| 49 So(tm.ValidateProtoMessage(&messages.SwarmingTask{ | 49 So(tm.ValidateProtoMessage(&messages.SwarmingTask{ |
| 50 » » » Server: "https://blah.com", | 50 » » » Server: "blah.com", |
| 51 Command: []string{"echo", "Hi!"}, | 51 Command: []string{"echo", "Hi!"}, |
| 52 }), ShouldBeNil) | 52 }), ShouldBeNil) |
| 53 }) | 53 }) |
| 54 | 54 |
| 55 Convey("ValidateProtoMessage wrong type", t, func() { | 55 Convey("ValidateProtoMessage wrong type", t, func() { |
| 56 So(tm.ValidateProtoMessage(&messages.NoopTask{}), ShouldErrLike,
"wrong type") | 56 So(tm.ValidateProtoMessage(&messages.NoopTask{}), ShouldErrLike,
"wrong type") |
| 57 }) | 57 }) |
| 58 | 58 |
| 59 Convey("ValidateProtoMessage empty", t, func() { | 59 Convey("ValidateProtoMessage empty", t, func() { |
| 60 So(tm.ValidateProtoMessage(tm.ProtoMessageType()), ShouldErrLike
, "expecting a non-empty SwarmingTask") | 60 So(tm.ValidateProtoMessage(tm.ProtoMessageType()), ShouldErrLike
, "expecting a non-empty SwarmingTask") |
| 61 }) | 61 }) |
| 62 | 62 |
| 63 Convey("ValidateProtoMessage validates URL", t, func() { | 63 Convey("ValidateProtoMessage validates URL", t, func() { |
| 64 call := func(url string) error { | 64 call := func(url string) error { |
| 65 return tm.ValidateProtoMessage(&messages.SwarmingTask{ | 65 return tm.ValidateProtoMessage(&messages.SwarmingTask{ |
| 66 Server: url, | 66 Server: url, |
| 67 Command: []string{"echo", "Hi!"}, | 67 Command: []string{"echo", "Hi!"}, |
| 68 }) | 68 }) |
| 69 } | 69 } |
| 70 So(call(""), ShouldErrLike, "field 'server' is required") | 70 So(call(""), ShouldErrLike, "field 'server' is required") |
| 71 So(call("%%%%"), ShouldErrLike, "invalid URL") | 71 So(call("%%%%"), ShouldErrLike, "invalid URL") |
| 72 » » So(call("/abc"), ShouldErrLike, "not an absolute url") | 72 » » So(call("/abc"), ShouldErrLike, "not a host root url") |
| 73 So(call("https://host/not-root"), ShouldErrLike, "not a host roo
t url") | 73 So(call("https://host/not-root"), ShouldErrLike, "not a host roo
t url") |
| 74 }) | 74 }) |
| 75 | 75 |
| 76 Convey("ValidateProtoMessage validates environ", t, func() { | 76 Convey("ValidateProtoMessage validates environ", t, func() { |
| 77 So(tm.ValidateProtoMessage(&messages.SwarmingTask{ | 77 So(tm.ValidateProtoMessage(&messages.SwarmingTask{ |
| 78 Server: "https://blah.com", | 78 Server: "https://blah.com", |
| 79 Command: []string{"echo", "Hi!"}, | 79 Command: []string{"echo", "Hi!"}, |
| 80 Env: []string{"not_kv_pair"}, | 80 Env: []string{"not_kv_pair"}, |
| 81 }), ShouldErrLike, "bad environment variable, not a 'key=value'
pair") | 81 }), ShouldErrLike, "bad environment variable, not a 'key=value'
pair") |
| 82 }) | 82 }) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 Name: statusCheckTimerName, | 204 Name: statusCheckTimerName, |
| 205 }, | 205 }, |
| 206 }) | 206 }) |
| 207 | 207 |
| 208 // Process finish notification. | 208 // Process finish notification. |
| 209 mockRunning = false | 209 mockRunning = false |
| 210 So(mgr.HandleNotification(c, ctl, &pubsub.PubsubMessage{}), Shou
ldBeNil) | 210 So(mgr.HandleNotification(c, ctl, &pubsub.PubsubMessage{}), Shou
ldBeNil) |
| 211 So(ctl.TaskState.Status, ShouldEqual, task.StatusSucceeded) | 211 So(ctl.TaskState.Status, ShouldEqual, task.StatusSucceeded) |
| 212 }) | 212 }) |
| 213 } | 213 } |
| OLD | NEW |