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

Side by Side Diff: go/src/infra/tools/cipd/uploader_test.go

Issue 1130733007: cipd: Add -tag option to 'create' and 'pkg-register' subcomands. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 7 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 | « go/src/infra/tools/cipd/uploader.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package cipd 5 package cipd
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "io/ioutil" 10 "io/ioutil"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 UploadOptions: UploadOptions{ 207 UploadOptions: UploadOptions{
208 Client: client, 208 Client: client,
209 Log: logging.DefaultLogger, 209 Log: logging.DefaultLogger,
210 }, 210 },
211 }) 211 })
212 So(err, ShouldBeNil) 212 So(err, ShouldBeNil)
213 So(uploaded.Bytes(), ShouldResemble, []byte(dataToUpload)) 213 So(uploaded.Bytes(), ShouldResemble, []byte(dataToUpload))
214 }) 214 })
215 } 215 }
216 216
217 func TestAttachTagsWhenReady(t *testing.T) {
218 Convey("Mocking clock", t, func() {
219 mockClock(time.Now())
220
221 Convey("attachTagsWhenReady works", func() {
222 remote := mockRemoteServiceWithExpectations([]expectedHT TPCall{
223 {
224 Method: "POST",
225 Path: "/_ah/api/repo/v1/tags",
226 Query: url.Values{
227 "instance_id": []string{"aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
228 "package_name": []string{"pkgnam e"},
229 },
230 Reply: `{"status": "PROCESSING_NOT_FINIS HED_YET"}`,
231 },
232 {
233 Method: "POST",
234 Path: "/_ah/api/repo/v1/tags",
235 Query: url.Values{
236 "instance_id": []string{"aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
237 "package_name": []string{"pkgnam e"},
238 },
239 Reply: `{"status": "SUCCESS"}`,
240 },
241 })
242 err := attachTagsWhenReady(
243 remote, "pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa",
244 []string{"tag1:value1"}, logging.DefaultLogger)
245 So(err, ShouldBeNil)
246 })
247
248 Convey("attachTagsWhenReady timeout", func() {
249 calls := []expectedHTTPCall{}
250 for i := 0; i < 20; i++ {
251 calls = append(calls, expectedHTTPCall{
252 Method: "POST",
253 Path: "/_ah/api/repo/v1/tags",
254 Query: url.Values{
255 "instance_id": []string{"aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
256 "package_name": []string{"pkgnam e"},
257 },
258 Reply: `{"status": "PROCESSING_NOT_FINIS HED_YET"}`,
259 })
260 }
261 remote := mockRemoteServiceWithExpectations(calls)
262 err := attachTagsWhenReady(
263 remote, "pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa",
264 []string{"tag1:value1"}, logging.DefaultLogger)
265 So(err, ShouldEqual, ErrAttachTagsTimeout)
266 })
267 })
268 }
269
217 func mockResumableUpload() { 270 func mockResumableUpload() {
218 prev := resumableUpload 271 prev := resumableUpload
219 resumableUpload = func(string, int64, UploadToCASOptions) error { 272 resumableUpload = func(string, int64, UploadToCASOptions) error {
220 return nil 273 return nil
221 } 274 }
222 Reset(func() { resumableUpload = prev }) 275 Reset(func() { resumableUpload = prev })
223 } 276 }
OLDNEW
« no previous file with comments | « go/src/infra/tools/cipd/uploader.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698