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

Unified Diff: go/src/infra/tools/cipd/remote_test.go

Issue 1194803002: Add a package listing API to cipd. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 6 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') | 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/remote_test.go
diff --git a/go/src/infra/tools/cipd/remote_test.go b/go/src/infra/tools/cipd/remote_test.go
index ed00422e425195c0f820b1434cd46337912dc3dd..453c07e2092e144ab3a1efadabdd07f59b3a07a6 100644
--- a/go/src/infra/tools/cipd/remote_test.go
+++ b/go/src/infra/tools/cipd/remote_test.go
@@ -109,6 +109,21 @@ func TestRemoteImpl(t *testing.T) {
return remote.setRef("some-ref", Pin{"pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"})
}
+ mockListPackages := func(c C, reply string) ([]string, []string, error) {
+ remote := mockRemoteImpl(c, []expectedHTTPCall{
+ {
+ Method: "GET",
+ Path: "/_ah/api/repo/v1/package/search",
+ Query: url.Values{
+ "path": []string{"pkgpath"},
+ "recursive": []string{"false"},
+ },
+ Reply: reply,
+ },
+ })
+ return remote.listPackages("pkgpath", false)
+ }
+
mockAttachTags := func(c C, tags []string, body, reply string) error {
remote := mockRemoteImpl(c, []expectedHTTPCall{
{
@@ -513,6 +528,33 @@ func TestRemoteImpl(t *testing.T) {
So(mockSetRef(c, `{"status":"ERROR", "error_message":"Blah"}`), ShouldNotBeNil)
})
+ Convey("listPackages SUCCESS", t, func(c C) {
+ pkgs, dirs, err := mockListPackages(c, `{
+ "status": "SUCCESS",
+ "packages": [
+ "pkgpath/fake1",
+ "pkgpath/fake2"
+ ],
+ "directories": []
+ }`)
+ So(err, ShouldBeNil)
+ So(pkgs, ShouldResemble, []string{
+ "pkgpath/fake1",
+ "pkgpath/fake2",
+ })
+ So(dirs, ShouldResemble, []string{})
+ })
+
+ Convey("listPackages ERROR", t, func(c C) {
+ pkgs, dirs, err := mockListPackages(c, `{
+ "status": "ERROR",
+ "error_message": "Some error message"
+ }`)
+ So(err, ShouldNotBeNil)
+ So(pkgs, ShouldBeNil)
+ So(dirs, ShouldBeNil)
+ })
+
Convey("attachTags SUCCESS", t, func(c C) {
err := mockAttachTags(
c, []string{"tag1:value1", "tag2:value2"},
« no previous file with comments | « go/src/infra/tools/cipd/remote.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698