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

Unified Diff: go/src/infra/tools/cipd/client_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
Index: go/src/infra/tools/cipd/client_test.go
diff --git a/go/src/infra/tools/cipd/client_test.go b/go/src/infra/tools/cipd/client_test.go
index bf23775aa22933b29c3b108ef766b0a55403d83f..bb4fe60153c5f921e47e9abbf5f656ac957e7fa5 100644
--- a/go/src/infra/tools/cipd/client_test.go
+++ b/go/src/infra/tools/cipd/client_test.go
@@ -367,6 +367,29 @@ func TestProcessEnsureFile(t *testing.T) {
})
}
+func TestListPackages(t *testing.T) {
+ call := func(c C, dirPath string, recursive bool, calls []expectedHTTPCall) ([]string, error) {
+ client := mockClient(c, "", calls)
+ return client.ListPackages(dirPath, recursive)
+ }
+
+ Convey("ListPackages merges directories", t, func(c C) {
+ out, err := call(c, "", true, []expectedHTTPCall{
+ {
+ Method: "GET",
+ Path: "/_ah/api/repo/v1/package/search",
+ Query: url.Values{
+ "path": []string{""},
+ "recursive": []string{"true"},
+ },
+ Reply: `{"status":"SUCCESS","packages":["dir/pkg"],"directories":["dir"]}`,
+ },
+ })
+ So(err, ShouldBeNil)
+ So(out, ShouldResemble, []string{"dir/", "dir/pkg"})
+ })
+}
+
func TestEnsurePackages(t *testing.T) {
Convey("Mocking temp dir", t, func() {
tempDir, err := ioutil.TempDir("", "cipd_test")

Powered by Google App Engine
This is Rietveld 408576698