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

Side by Side Diff: scheduler/appengine/task/swarming/swarming_test.go

Issue 2991213003: scheduler: Make 'https://' optional in 'server' config field. (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « scheduler/appengine/task/swarming/swarming.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « scheduler/appengine/task/swarming/swarming.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698