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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/tools/cipd/uploader.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cipd/uploader_test.go
diff --git a/go/src/infra/tools/cipd/uploader_test.go b/go/src/infra/tools/cipd/uploader_test.go
index 5678d329cf8de410625912d32ed93f37702a6c5d..11d11287421ca30b3b70c1dd16ab0b3d6e90017f 100644
--- a/go/src/infra/tools/cipd/uploader_test.go
+++ b/go/src/infra/tools/cipd/uploader_test.go
@@ -214,6 +214,59 @@ func TestResumableUpload(t *testing.T) {
})
}
+func TestAttachTagsWhenReady(t *testing.T) {
+ Convey("Mocking clock", t, func() {
+ mockClock(time.Now())
+
+ Convey("attachTagsWhenReady works", func() {
+ remote := mockRemoteServiceWithExpectations([]expectedHTTPCall{
+ {
+ Method: "POST",
+ Path: "/_ah/api/repo/v1/tags",
+ Query: url.Values{
+ "instance_id": []string{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
+ "package_name": []string{"pkgname"},
+ },
+ Reply: `{"status": "PROCESSING_NOT_FINISHED_YET"}`,
+ },
+ {
+ Method: "POST",
+ Path: "/_ah/api/repo/v1/tags",
+ Query: url.Values{
+ "instance_id": []string{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
+ "package_name": []string{"pkgname"},
+ },
+ Reply: `{"status": "SUCCESS"}`,
+ },
+ })
+ err := attachTagsWhenReady(
+ remote, "pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ []string{"tag1:value1"}, logging.DefaultLogger)
+ So(err, ShouldBeNil)
+ })
+
+ Convey("attachTagsWhenReady timeout", func() {
+ calls := []expectedHTTPCall{}
+ for i := 0; i < 20; i++ {
+ calls = append(calls, expectedHTTPCall{
+ Method: "POST",
+ Path: "/_ah/api/repo/v1/tags",
+ Query: url.Values{
+ "instance_id": []string{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
+ "package_name": []string{"pkgname"},
+ },
+ Reply: `{"status": "PROCESSING_NOT_FINISHED_YET"}`,
+ })
+ }
+ remote := mockRemoteServiceWithExpectations(calls)
+ err := attachTagsWhenReady(
+ remote, "pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ []string{"tag1:value1"}, logging.DefaultLogger)
+ So(err, ShouldEqual, ErrAttachTagsTimeout)
+ })
+ })
+}
+
func mockResumableUpload() {
prev := resumableUpload
resumableUpload = func(string, int64, UploadToCASOptions) error {
« 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