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

Side by Side Diff: scheduler/appengine/task/buildbucket/buildbucket_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
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 28 matching lines...) Expand all
39 Server: "https://blah.com", 39 Server: "https://blah.com",
40 Bucket: "bucket", 40 Bucket: "bucket",
41 Builder: "builder", 41 Builder: "builder",
42 Tags: []string{"a:b", "c:d"}, 42 Tags: []string{"a:b", "c:d"},
43 Properties: []string{"a:b", "c:d"}, 43 Properties: []string{"a:b", "c:d"},
44 }), ShouldBeNil) 44 }), ShouldBeNil)
45 }) 45 })
46 46
47 Convey("ValidateProtoMessage passes good minimal msg", t, func() { 47 Convey("ValidateProtoMessage passes good minimal msg", t, func() {
48 So(tm.ValidateProtoMessage(&messages.BuildbucketTask{ 48 So(tm.ValidateProtoMessage(&messages.BuildbucketTask{
49 » » » Server: "https://blah.com", 49 » » » Server: "blah.com",
50 Bucket: "bucket", 50 Bucket: "bucket",
51 Builder: "builder", 51 Builder: "builder",
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 BuildbucketTask") 60 So(tm.ValidateProtoMessage(tm.ProtoMessageType()), ShouldErrLike , "expecting a non-empty BuildbucketTask")
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.BuildbucketTask { 65 return tm.ValidateProtoMessage(&messages.BuildbucketTask {
66 Server: url, 66 Server: url,
67 Bucket: "bucket", 67 Bucket: "bucket",
68 Builder: "builder", 68 Builder: "builder",
69 }) 69 })
70 } 70 }
71 So(call(""), ShouldErrLike, "field 'server' is required") 71 So(call(""), ShouldErrLike, "field 'server' is required")
72 So(call("%%%%"), ShouldErrLike, "invalid URL") 72 So(call("%%%%"), ShouldErrLike, "invalid URL")
73 » » So(call("/abc"), ShouldErrLike, "not an absolute url") 73 » » So(call("/abc"), ShouldErrLike, "not a host root url")
74 So(call("https://host/not-root"), ShouldErrLike, "not a host roo t url") 74 So(call("https://host/not-root"), ShouldErrLike, "not a host roo t url")
75 }) 75 })
76 76
77 Convey("ValidateProtoMessage needs bucket", t, func() { 77 Convey("ValidateProtoMessage needs bucket", t, func() {
78 So(tm.ValidateProtoMessage(&messages.BuildbucketTask{ 78 So(tm.ValidateProtoMessage(&messages.BuildbucketTask{
79 Server: "https://blah.com", 79 Server: "https://blah.com",
80 Builder: "builder", 80 Builder: "builder",
81 }), ShouldErrLike, "'bucket' field is required") 81 }), ShouldErrLike, "'bucket' field is required")
82 }) 82 })
83 83
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 Name: statusCheckTimerName, 202 Name: statusCheckTimerName,
203 }, 203 },
204 }) 204 })
205 205
206 // Process finish notification. 206 // Process finish notification.
207 mockRunning = false 207 mockRunning = false
208 So(mgr.HandleNotification(c, ctl, &pubsub.PubsubMessage{}), Shou ldBeNil) 208 So(mgr.HandleNotification(c, ctl, &pubsub.PubsubMessage{}), Shou ldBeNil)
209 So(ctl.TaskState.Status, ShouldEqual, task.StatusSucceeded) 209 So(ctl.TaskState.Status, ShouldEqual, task.StatusSucceeded)
210 }) 210 })
211 } 211 }
OLDNEW
« no previous file with comments | « scheduler/appengine/task/buildbucket/buildbucket.go ('k') | scheduler/appengine/task/swarming/swarming.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698