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

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

Issue 1145423002: cipd: Client can resolve tags to instance IDs. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: cipd-resolve-version 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
« go/src/infra/tools/cipd/remote.go ('K') | « 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 bc70e9f654658ebf323b5970bbd9ae14f036b7fe..21de3fa9a616dbbd3726995f1c3970dd8bb65315 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.attachTags(Pin{"pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, tags)
}
+ mockResolveVersion := func(c C, reply string) (Pin, error) {
+ remote := mockRemoteImpl(c, []expectedHTTPCall{
+ {
+ Method: "GET",
+ Path: "/_ah/api/repo/v1/instance/resolve",
+ Query: url.Values{
+ "package_name": []string{"pkgname"},
+ "version": []string{"tag_key:value"},
+ },
+ Reply: reply,
+ },
+ })
+ return remote.resolveVersion("pkgname", "tag_key:value")
+ }
+
Convey("makeRequest POST works", t, func(c C) {
remote := mockRemoteImpl(c, []expectedHTTPCall{
{
@@ -492,6 +507,48 @@ func TestRemoteImpl(t *testing.T) {
`{"status":"ERROR", "error_message":"Blah"}`)
So(err, ShouldNotBeNil)
})
+
+ Convey("resolveVersion SUCCESS", t, func(c C) {
+ pin, err := mockResolveVersion(c, `{
+ "status": "SUCCESS",
+ "instance_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ }`)
+ So(err, ShouldBeNil)
+ So(pin, ShouldResemble, Pin{"pkgname", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"})
+ })
+
+ Convey("resolveVersion SUCCESS and bad instance ID", t, func(c C) {
+ _, err := mockResolveVersion(c, `{
+ "status": "SUCCESS",
+ "instance_id": "bad_id"
+ }`)
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("resolveVersion PACKAGE_NOT_FOUND", t, func(c C) {
+ _, err := mockResolveVersion(c, `{"status": "PACKAGE_NOT_FOUND"}`)
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("resolveVersion INSTANCE_NOT_FOUND", t, func(c C) {
+ _, err := mockResolveVersion(c, `{"status": "INSTANCE_NOT_FOUND"}`)
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("resolveVersion AMBIGUOUS_VERSION", t, func(c C) {
+ _, err := mockResolveVersion(c, `{"status": "AMBIGUOUS_VERSION"}`)
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("resolveVersion ERROR", t, func(c C) {
+ _, err := mockResolveVersion(c, `{"status": "ERROR", "error_message":"Blah"}`)
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("resolveVersion bad status", t, func(c C) {
+ _, err := mockResolveVersion(c, `{"status": "HUH?"}`)
+ So(err, ShouldNotBeNil)
+ })
}
////////////////////////////////////////////////////////////////////////////////
« go/src/infra/tools/cipd/remote.go ('K') | « 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