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

Unified Diff: cipd/client/cipd/remote_test.go

Issue 2509803002: Add cipd selfupdate command. (Closed)
Patch Set: Add additional early-exit Created 4 years, 1 month 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 | « cipd/client/cipd/remote.go ('k') | cipd/client/cmd/cipd/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cipd/remote_test.go
diff --git a/cipd/client/cipd/remote_test.go b/cipd/client/cipd/remote_test.go
index 48910ad5681ff0bc2eae44beb795e884247510ea..d0b9003469ff6e534804effddc5459ef8e44f890 100644
--- a/cipd/client/cipd/remote_test.go
+++ b/cipd/client/cipd/remote_test.go
@@ -83,6 +83,22 @@ func TestRemoteImpl(t *testing.T) {
return remote.fetchInstance(ctx, Pin{"pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"})
}
+ mockFetchClientBinaryInfo := func(c C, reply string) (*fetchClientBinaryInfoResponse, error) {
+ remote := mockRemoteImpl(c, []expectedHTTPCall{
+ {
+ Method: "GET",
+ Path: "/_ah/api/repo/v1/client",
+ Query: url.Values{
+ "package_name": []string{"infra/tools/cipd/mac-amd64"},
+ "instance_id": []string{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
+ },
+ Reply: reply,
+ },
+ })
+ return remote.fetchClientBinaryInfo(ctx,
+ Pin{"infra/tools/cipd/mac-amd64", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"})
+ }
+
mockFetchTags := func(c C, reply string, tags []string) ([]TagInfo, error) {
query := url.Values{
"package_name": []string{"pkgname"},
@@ -524,6 +540,61 @@ func TestRemoteImpl(t *testing.T) {
So(result, ShouldBeNil)
})
+ Convey("fetchClientBinaryInfo SUCCESS", t, func(c C) {
+ result, err := mockFetchClientBinaryInfo(c, `{
+ "status": "SUCCESS",
+ "instance": {
+ "instance_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "registered_by": "user:a@example.com",
+ "registered_ts": "1420244414571500",
+ "package_name": "infra/tools/cipd/mac-amd64"
+ },
+ "client_binary": {
+ "file_name": "cipd",
+ "sha1": "c52a8ffe7522302e5658fd7f1eb9e2dfd93c0b80",
+ "fetch_url": "https://storage.googleapis.com/example?params=yes",
+ "size": "10120188"
+ },
+ "kind": "repo#resourcesItem",
+ "etag": "\"klmD7St9j1caKhEua58kkAgnm0A/GCbN4lyfRwANQtP3NW9-SWMggwY\""
+ }`)
+ So(err, ShouldBeNil)
+ So(result, ShouldResemble, &fetchClientBinaryInfoResponse{
+ instance: &InstanceInfo{
+ Pin{"infra/tools/cipd/mac-amd64", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
+ "user:a@example.com",
+ UnixTime(time.Unix(0, 1420244414571500000)),
+ },
+ clientBinary: &clientBinary{
+ "cipd",
+ "c52a8ffe7522302e5658fd7f1eb9e2dfd93c0b80",
+ "https://storage.googleapis.com/example?params=yes",
+ 10120188,
+ },
+ })
+ })
+
+ Convey("fetchClientBinaryInfo PACKAGE_NOT_FOUND", t, func(c C) {
+ result, err := mockFetchClientBinaryInfo(c, `{"status": "PACKAGE_NOT_FOUND"}`)
+ So(err, ShouldNotBeNil)
+ So(result, ShouldBeNil)
+ })
+
+ Convey("fetchClientBinaryInfo INSTANCE_NOT_FOUND", t, func(c C) {
+ result, err := mockFetchClientBinaryInfo(c, `{"status": "INSTANCE_NOT_FOUND"}`)
+ So(err, ShouldNotBeNil)
+ So(result, ShouldBeNil)
+ })
+
+ Convey("fetchClientBinaryInfo ERROR", t, func(c C) {
+ result, err := mockFetchClientBinaryInfo(c, `{
+ "status": "ERROR",
+ "error_message": "Some error message"
+ }`)
+ So(err, ShouldNotBeNil)
+ So(result, ShouldBeNil)
+ })
+
Convey("fetchTags SUCCESS", t, func(c C) {
result, err := mockFetchTags(c, `{
"status": "SUCCESS",
« no previous file with comments | « cipd/client/cipd/remote.go ('k') | cipd/client/cmd/cipd/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698