[arvados] updated: 2.6.0-214-g61da7aaa2

git repository hosting git at public.arvados.org
Wed May 31 14:04:25 UTC 2023


Summary of changes:
 sdk/go/arvados/client.go      |  6 ++++++
 sdk/go/arvados/client_test.go | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

       via  61da7aaa22e071f83fe8bdae4e8fb06a6c3779d8 (commit)
      from  67e695ce526e9991649bd4d619338c767bbc1e05 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 61da7aaa22e071f83fe8bdae4e8fb06a6c3779d8
Author: Tom Clegg <tom at curii.com>
Date:   Wed May 31 09:59:30 2023 -0400

    20541: Auto unselect fields if response body will not be read.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/client.go b/sdk/go/arvados/client.go
index 6316d1bed..e8442e857 100644
--- a/sdk/go/arvados/client.go
+++ b/sdk/go/arvados/client.go
@@ -502,6 +502,12 @@ func (c *Client) RequestAndDecodeContext(ctx context.Context, dst interface{}, m
 	if err != nil {
 		return err
 	}
+	if dst == nil {
+		if urlValues == nil {
+			urlValues = url.Values{}
+		}
+		urlValues["select"] = []string{`["uuid"]`}
+	}
 	if urlValues == nil {
 		// Nothing to send
 	} else if body != nil || ((method == "GET" || method == "HEAD") && len(urlValues.Encode()) < 1000) {
diff --git a/sdk/go/arvados/client_test.go b/sdk/go/arvados/client_test.go
index 422aca9f6..41feb4e19 100644
--- a/sdk/go/arvados/client_test.go
+++ b/sdk/go/arvados/client_test.go
@@ -169,6 +169,44 @@ func (*clientSuite) TestAnythingToValues(c *check.C) {
 	}
 }
 
+// select=["uuid"] is added automatically when RequestAndDecode's
+// destination argument is nil.
+func (*clientSuite) TestAutoSelectUUID(c *check.C) {
+	var req *http.Request
+	var err error
+	server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+		c.Check(r.ParseForm(), check.IsNil)
+		req = r
+		w.Write([]byte("{}"))
+	}))
+	client := Client{
+		APIHost:   strings.TrimPrefix(server.URL, "https://"),
+		AuthToken: "zzz",
+		Insecure:  true,
+		Timeout:   2 * time.Second,
+	}
+
+	req = nil
+	err = client.RequestAndDecode(nil, http.MethodPost, "test", nil, nil)
+	c.Check(err, check.IsNil)
+	c.Check(req.FormValue("select"), check.Equals, `["uuid"]`)
+
+	req = nil
+	err = client.RequestAndDecode(nil, http.MethodGet, "test", nil, nil)
+	c.Check(err, check.IsNil)
+	c.Check(req.FormValue("select"), check.Equals, `["uuid"]`)
+
+	req = nil
+	err = client.RequestAndDecode(nil, http.MethodGet, "test", nil, map[string]interface{}{"select": []string{"blergh"}})
+	c.Check(err, check.IsNil)
+	c.Check(req.FormValue("select"), check.Equals, `["uuid"]`)
+
+	req = nil
+	err = client.RequestAndDecode(&struct{}{}, http.MethodGet, "test", nil, map[string]interface{}{"select": []string{"blergh"}})
+	c.Check(err, check.IsNil)
+	c.Check(req.FormValue("select"), check.Equals, `["blergh"]`)
+}
+
 func (*clientSuite) TestLoadConfig(c *check.C) {
 	oldenv := os.Environ()
 	defer func() {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list