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

Unified Diff: go/src/infra/tools/cipd/remote_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/remote.go ('k') | go/src/infra/tools/cipd/uploader.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cipd/remote_test.go
diff --git a/go/src/infra/tools/cipd/remote_test.go b/go/src/infra/tools/cipd/remote_test.go
index 427d245e99ef74da99dc70cf8271fa92fcf73973..f8e40b466e72cc76264cc2b502fffaf3bbd87350 100644
--- a/go/src/infra/tools/cipd/remote_test.go
+++ b/go/src/infra/tools/cipd/remote_test.go
@@ -84,6 +84,20 @@ func TestRemoteService(t *testing.T) {
return remote.modifyACL("pkgname", changes)
}
+ mockAttachTags := func(c C, tags []string, request, response string) error {
+ remote := mockRemoteService(func(w http.ResponseWriter, r *http.Request) {
+ c.So(r.URL.Path, ShouldEqual, "/_ah/api/repo/v1/tags")
+ c.So(r.URL.Query().Get("package_name"), ShouldEqual, "pkgname")
+ c.So(r.URL.Query().Get("instance_id"), ShouldEqual, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
+ c.So(r.Method, ShouldEqual, "POST")
+ body, err := ioutil.ReadAll(r.Body)
+ c.So(err, ShouldBeNil)
+ c.So(string(body), ShouldEqual, request)
+ w.Write([]byte(response))
+ })
+ return remote.attachTags("pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", tags)
+ }
+
Convey("makeRequest POST works", t, func(c C) {
remote := mockRemoteService(func(w http.ResponseWriter, r *http.Request) {
c.So(r.Method, ShouldEqual, "POST")
@@ -434,6 +448,40 @@ func TestRemoteService(t *testing.T) {
}`)
So(err, ShouldNotBeNil)
})
+
+ Convey("attachTags SUCCESS", t, func(c C) {
+ err := mockAttachTags(
+ c, []string{"tag1:value1", "tag2:value2"},
+ `{"tags":["tag1:value1","tag2:value2"]}`,
+ `{"status":"SUCCESS"}`)
+ So(err, ShouldBeNil)
+ })
+
+ Convey("attachTags no tags", t, func(c C) {
+ err := mockAttachTags(c, nil, "", "")
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("attachTags bad tag", t, func(c C) {
+ err := mockAttachTags(c, []string{"BADTAG"}, "", "")
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("attachTags PROCESSING_NOT_FINISHED_YET", t, func(c C) {
+ err := mockAttachTags(
+ c, []string{"tag1:value1", "tag2:value2"},
+ `{"tags":["tag1:value1","tag2:value2"]}`,
+ `{"status":"PROCESSING_NOT_FINISHED_YET", "error_message":"Blah"}`)
+ So(err, ShouldResemble, &pendingProcessingError{message: "Blah"})
+ })
+
+ Convey("attachTags ERROR", t, func(c C) {
+ err := mockAttachTags(
+ c, []string{"tag1:value1", "tag2:value2"},
+ `{"tags":["tag1:value1","tag2:value2"]}`,
+ `{"status":"ERROR", "error_message":"Blah"}`)
+ So(err, ShouldNotBeNil)
+ })
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « go/src/infra/tools/cipd/remote.go ('k') | go/src/infra/tools/cipd/uploader.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698