14287: Unit-test router with stubbed API.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 18 Jun 2019 14:52:45 +0000 (10:52 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Tue, 18 Jun 2019 14:52:45 +0000 (10:52 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/controller/router/checker.go [new file with mode: 0644]
lib/controller/router/router.go
lib/controller/router/router_test.go
sdk/go/arvadostest/api.go [new file with mode: 0644]

diff --git a/lib/controller/router/checker.go b/lib/controller/router/checker.go
new file mode 100644 (file)
index 0000000..b9fec91
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+package router
+
+import (
+       "reflect"
+       "runtime"
+
+       check "gopkg.in/check.v1"
+)
+
+var isMethodNamed check.Checker = &chkIsMethodNamed{
+       CheckerInfo: &check.CheckerInfo{
+               Name:   "isMethodNamed",
+               Params: []string{"obtained", "expected"},
+       },
+}
+
+type chkIsMethodNamed struct{ *check.CheckerInfo }
+
+func (*chkIsMethodNamed) Check(params []interface{}, names []string) (bool, string) {
+       methodName := runtime.FuncForPC(reflect.ValueOf(params[0]).Pointer()).Name()
+       regex := `.*\)\.` + params[1].(string) + `(-.*)?`
+       return check.Matches.Check([]interface{}{methodName, regex}, names)
+}
index 1d08046b691544f4e29e297b6a1e855e75ef13a5..909667c5456e66a85655a04733b2796bfb2d3186 100644 (file)
@@ -29,11 +29,11 @@ func New(cluster *arvados.Cluster) *router {
                mux: httprouter.New(),
                fed: federation.New(cluster),
        }
-       rtr.addRoutes(cluster)
+       rtr.addRoutes()
        return rtr
 }
 
-func (rtr *router) addRoutes(cluster *arvados.Cluster) {
+func (rtr *router) addRoutes() {
        for _, route := range []struct {
                endpoint    arvados.APIEndpoint
                defaultOpts func() interface{}
@@ -248,6 +248,9 @@ func (rtr *router) addRoutes(cluster *arvados.Cluster) {
        rtr.mux.NotFound = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
                httpserver.Errors(w, []string{"API endpoint not found"}, http.StatusNotFound)
        })
+       rtr.mux.MethodNotAllowed = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+               httpserver.Errors(w, []string{"API endpoint not found"}, http.StatusMethodNotAllowed)
+       })
 }
 
 func (rtr *router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
index 63e5678ec7b9e529af4b2ebe0e5bc79966966baf..4e6b1617330ffa47c405d2c9e708ee69e979e641 100644 (file)
@@ -17,6 +17,7 @@ import (
 
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/arvadostest"
+       "github.com/julienschmidt/httprouter"
        check "gopkg.in/check.v1"
 )
 
@@ -28,41 +29,148 @@ func Test(t *testing.T) {
 var _ = check.Suite(&RouterSuite{})
 
 type RouterSuite struct {
-       rtr *router
+       rtr  *router
+       stub arvadostest.APIStub
 }
 
 func (s *RouterSuite) SetUpTest(c *check.C) {
+       s.stub = arvadostest.APIStub{}
+       s.rtr = &router{
+               mux: httprouter.New(),
+               fed: &s.stub,
+       }
+       s.rtr.addRoutes()
+}
+
+func (s *RouterSuite) TestOptions(c *check.C) {
+       token := arvadostest.ActiveToken
+       for _, trial := range []struct {
+               method       string
+               path         string
+               header       http.Header
+               body         string
+               shouldStatus int // zero value means 200
+               shouldCall   string
+               withOptions  interface{}
+       }{
+               {
+                       method:      "GET",
+                       path:        "/arvados/v1/collections/" + arvadostest.FooCollection,
+                       shouldCall:  "CollectionGet",
+                       withOptions: arvados.GetOptions{UUID: arvadostest.FooCollection},
+               },
+               {
+                       method:      "PUT",
+                       path:        "/arvados/v1/collections/" + arvadostest.FooCollection,
+                       shouldCall:  "CollectionUpdate",
+                       withOptions: arvados.UpdateOptions{UUID: arvadostest.FooCollection},
+               },
+               {
+                       method:      "PATCH",
+                       path:        "/arvados/v1/collections/" + arvadostest.FooCollection,
+                       shouldCall:  "CollectionUpdate",
+                       withOptions: arvados.UpdateOptions{UUID: arvadostest.FooCollection},
+               },
+               {
+                       method:      "DELETE",
+                       path:        "/arvados/v1/collections/" + arvadostest.FooCollection,
+                       shouldCall:  "CollectionDelete",
+                       withOptions: arvados.DeleteOptions{UUID: arvadostest.FooCollection},
+               },
+               {
+                       method:      "POST",
+                       path:        "/arvados/v1/collections",
+                       shouldCall:  "CollectionCreate",
+                       withOptions: arvados.CreateOptions{},
+               },
+               {
+                       method:      "GET",
+                       path:        "/arvados/v1/collections",
+                       shouldCall:  "CollectionList",
+                       withOptions: arvados.ListOptions{Limit: -1},
+               },
+               {
+                       method:      "GET",
+                       path:        "/arvados/v1/collections?limit=123&offset=456&include_trash=true&include_old_versions=1",
+                       shouldCall:  "CollectionList",
+                       withOptions: arvados.ListOptions{Limit: 123, Offset: 456, IncludeTrash: true, IncludeOldVersions: true},
+               },
+               {
+                       method:      "POST",
+                       path:        "/arvados/v1/collections?limit=123&_method=GET",
+                       body:        `{"offset":456,"include_trash":true,"include_old_versions":true}`,
+                       shouldCall:  "CollectionList",
+                       withOptions: arvados.ListOptions{Limit: 123, Offset: 456, IncludeTrash: true, IncludeOldVersions: true},
+               },
+               {
+                       method:      "POST",
+                       path:        "/arvados/v1/collections?limit=123",
+                       body:        "offset=456&include_trash=true&include_old_versions=1&_method=GET",
+                       header:      http.Header{"Content-Type": {"application/x-www-form-urlencoded"}},
+                       shouldCall:  "CollectionList",
+                       withOptions: arvados.ListOptions{Limit: 123, Offset: 456, IncludeTrash: true, IncludeOldVersions: true},
+               },
+               {
+                       method:       "PATCH",
+                       path:         "/arvados/v1/collections",
+                       shouldStatus: http.StatusMethodNotAllowed,
+               },
+               {
+                       method:       "PUT",
+                       path:         "/arvados/v1/collections",
+                       shouldStatus: http.StatusMethodNotAllowed,
+               },
+               {
+                       method:       "DELETE",
+                       path:         "/arvados/v1/collections",
+                       shouldStatus: http.StatusMethodNotAllowed,
+               },
+       } {
+               // Reset calls captured in previous trial
+               s.stub = arvadostest.APIStub{}
+
+               c.Logf("trial: %#v", trial)
+               _, rr, _ := doRequest(c, s.rtr, token, trial.method, trial.path, trial.header, bytes.NewBufferString(trial.body))
+               if trial.shouldStatus == 0 {
+                       c.Check(rr.Code, check.Equals, http.StatusOK)
+               } else {
+                       c.Check(rr.Code, check.Equals, trial.shouldStatus)
+               }
+               calls := s.stub.Calls(nil)
+               if trial.shouldCall == "" {
+                       c.Check(calls, check.HasLen, 0)
+               } else if len(calls) != 1 {
+                       c.Check(calls, check.HasLen, 1)
+               } else {
+                       c.Check(calls[0].Method, isMethodNamed, trial.shouldCall)
+                       c.Check(calls[0].Options, check.DeepEquals, trial.withOptions)
+               }
+       }
+}
+
+var _ = check.Suite(&RouterIntegrationSuite{})
+
+type RouterIntegrationSuite struct {
+       rtr *router
+}
+
+func (s *RouterIntegrationSuite) SetUpTest(c *check.C) {
        cluster := &arvados.Cluster{}
        cluster.TLS.Insecure = true
        arvadostest.SetServiceURL(&cluster.Services.RailsAPI, "https://"+os.Getenv("ARVADOS_TEST_API_HOST"))
        s.rtr = New(cluster)
 }
 
-func (s *RouterSuite) TearDownSuite(c *check.C) {
+func (s *RouterIntegrationSuite) TearDownSuite(c *check.C) {
        err := arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil)
        c.Check(err, check.IsNil)
 }
 
-func (s *RouterSuite) doRequest(c *check.C, token, method, path string, hdrs http.Header, body io.Reader) (*http.Request, *httptest.ResponseRecorder, map[string]interface{}) {
-       req := httptest.NewRequest(method, path, body)
-       for k, v := range hdrs {
-               req.Header[k] = v
-       }
-       req.Header.Set("Authorization", "Bearer "+token)
-       rr := httptest.NewRecorder()
-       s.rtr.ServeHTTP(rr, req)
-       c.Logf("response body: %s", rr.Body.String())
-       var jresp map[string]interface{}
-       err := json.Unmarshal(rr.Body.Bytes(), &jresp)
-       c.Check(err, check.IsNil)
-       return req, rr, jresp
-}
-
-func (s *RouterSuite) TestCollectionResponses(c *check.C) {
+func (s *RouterIntegrationSuite) TestCollectionResponses(c *check.C) {
        token := arvadostest.ActiveTokenV2
 
        // Check "get collection" response has "kind" key
-       _, rr, jresp := s.doRequest(c, token, "GET", `/arvados/v1/collections`, nil, bytes.NewBufferString(`{"include_trash":true}`))
+       _, rr, jresp := doRequest(c, s.rtr, token, "GET", `/arvados/v1/collections`, nil, bytes.NewBufferString(`{"include_trash":true}`))
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["items"], check.FitsTypeOf, []interface{}{})
        c.Check(jresp["kind"], check.Equals, "arvados#collectionList")
@@ -76,7 +184,7 @@ func (s *RouterSuite) TestCollectionResponses(c *check.C) {
                `,"select":["name"]`,
                `,"select":["uuid"]`,
        } {
-               _, rr, jresp = s.doRequest(c, token, "GET", `/arvados/v1/collections`, nil, bytes.NewBufferString(`{"where":{"uuid":["`+arvadostest.FooCollection+`"]}`+selectj+`}`))
+               _, rr, jresp = doRequest(c, s.rtr, token, "GET", `/arvados/v1/collections`, nil, bytes.NewBufferString(`{"where":{"uuid":["`+arvadostest.FooCollection+`"]}`+selectj+`}`))
                c.Check(rr.Code, check.Equals, http.StatusOK)
                c.Check(jresp["items"], check.FitsTypeOf, []interface{}{})
                c.Check(jresp["items_available"], check.FitsTypeOf, float64(0))
@@ -101,22 +209,22 @@ func (s *RouterSuite) TestCollectionResponses(c *check.C) {
        }
 
        // Check "create collection" response has "kind" key
-       _, rr, jresp = s.doRequest(c, token, "POST", `/arvados/v1/collections`, http.Header{"Content-Type": {"application/x-www-form-urlencoded"}}, bytes.NewBufferString(`ensure_unique_name=true`))
+       _, rr, jresp = doRequest(c, s.rtr, token, "POST", `/arvados/v1/collections`, http.Header{"Content-Type": {"application/x-www-form-urlencoded"}}, bytes.NewBufferString(`ensure_unique_name=true`))
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["uuid"], check.FitsTypeOf, "")
        c.Check(jresp["kind"], check.Equals, "arvados#collection")
 }
 
-func (s *RouterSuite) TestContainerList(c *check.C) {
+func (s *RouterIntegrationSuite) TestContainerList(c *check.C) {
        token := arvadostest.ActiveTokenV2
 
-       _, rr, jresp := s.doRequest(c, token, "GET", `/arvados/v1/containers?limit=0`, nil, nil)
+       _, rr, jresp := doRequest(c, s.rtr, token, "GET", `/arvados/v1/containers?limit=0`, nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["items_available"], check.FitsTypeOf, float64(0))
        c.Check(jresp["items_available"].(float64) > 2, check.Equals, true)
        c.Check(jresp["items"], check.HasLen, 0)
 
-       _, rr, jresp = s.doRequest(c, token, "GET", `/arvados/v1/containers?limit=2&select=["uuid","command"]`, nil, nil)
+       _, rr, jresp = doRequest(c, s.rtr, token, "GET", `/arvados/v1/containers?limit=2&select=["uuid","command"]`, nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["items_available"], check.FitsTypeOf, float64(0))
        c.Check(jresp["items_available"].(float64) > 2, check.Equals, true)
@@ -127,7 +235,7 @@ func (s *RouterSuite) TestContainerList(c *check.C) {
        c.Check(item0["command"].([]interface{})[0], check.FitsTypeOf, "")
        c.Check(item0["mounts"], check.IsNil)
 
-       _, rr, jresp = s.doRequest(c, token, "GET", `/arvados/v1/containers`, nil, nil)
+       _, rr, jresp = doRequest(c, s.rtr, token, "GET", `/arvados/v1/containers`, nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["items_available"], check.FitsTypeOf, float64(0))
        c.Check(jresp["items_available"].(float64) > 2, check.Equals, true)
@@ -140,31 +248,31 @@ func (s *RouterSuite) TestContainerList(c *check.C) {
        c.Check(item0["mounts"], check.NotNil)
 }
 
-func (s *RouterSuite) TestContainerLock(c *check.C) {
+func (s *RouterIntegrationSuite) TestContainerLock(c *check.C) {
        uuid := arvadostest.QueuedContainerUUID
        token := arvadostest.AdminToken
-       _, rr, jresp := s.doRequest(c, token, "POST", "/arvados/v1/containers/"+uuid+"/lock", nil, nil)
+       _, rr, jresp := doRequest(c, s.rtr, token, "POST", "/arvados/v1/containers/"+uuid+"/lock", nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["uuid"], check.HasLen, 27)
        c.Check(jresp["state"], check.Equals, "Locked")
-       _, rr, jresp = s.doRequest(c, token, "POST", "/arvados/v1/containers/"+uuid+"/lock", nil, nil)
+       _, rr, jresp = doRequest(c, s.rtr, token, "POST", "/arvados/v1/containers/"+uuid+"/lock", nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusUnprocessableEntity)
        c.Check(rr.Body.String(), check.Not(check.Matches), `.*"uuid":.*`)
-       _, rr, jresp = s.doRequest(c, token, "POST", "/arvados/v1/containers/"+uuid+"/unlock", nil, nil)
+       _, rr, jresp = doRequest(c, s.rtr, token, "POST", "/arvados/v1/containers/"+uuid+"/unlock", nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["uuid"], check.HasLen, 27)
        c.Check(jresp["state"], check.Equals, "Queued")
        c.Check(jresp["environment"], check.IsNil)
-       _, rr, jresp = s.doRequest(c, token, "POST", "/arvados/v1/containers/"+uuid+"/unlock", nil, nil)
+       _, rr, jresp = doRequest(c, s.rtr, token, "POST", "/arvados/v1/containers/"+uuid+"/unlock", nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusUnprocessableEntity)
        c.Check(jresp["uuid"], check.IsNil)
 }
 
-func (s *RouterSuite) TestFullTimestampsInResponse(c *check.C) {
+func (s *RouterIntegrationSuite) TestFullTimestampsInResponse(c *check.C) {
        uuid := arvadostest.CollectionReplicationDesired2Confirmed2UUID
        token := arvadostest.ActiveTokenV2
 
-       _, rr, jresp := s.doRequest(c, token, "GET", `/arvados/v1/collections/`+uuid, nil, nil)
+       _, rr, jresp := doRequest(c, s.rtr, token, "GET", `/arvados/v1/collections/`+uuid, nil, nil)
        c.Check(rr.Code, check.Equals, http.StatusOK)
        c.Check(jresp["uuid"], check.Equals, uuid)
        expectNS := map[string]int{
@@ -181,7 +289,7 @@ func (s *RouterSuite) TestFullTimestampsInResponse(c *check.C) {
        }
 }
 
-func (s *RouterSuite) TestSelectParam(c *check.C) {
+func (s *RouterIntegrationSuite) TestSelectParam(c *check.C) {
        uuid := arvadostest.QueuedContainerUUID
        token := arvadostest.ActiveTokenV2
        for _, sel := range [][]string{
@@ -191,7 +299,7 @@ func (s *RouterSuite) TestSelectParam(c *check.C) {
        } {
                j, err := json.Marshal(sel)
                c.Assert(err, check.IsNil)
-               _, rr, resp := s.doRequest(c, token, "GET", "/arvados/v1/containers/"+uuid+"?select="+string(j), nil, nil)
+               _, rr, resp := doRequest(c, s.rtr, token, "GET", "/arvados/v1/containers/"+uuid+"?select="+string(j), nil, nil)
                c.Check(rr.Code, check.Equals, http.StatusOK)
 
                c.Check(resp["kind"], check.Equals, "arvados#container")
@@ -203,7 +311,7 @@ func (s *RouterSuite) TestSelectParam(c *check.C) {
        }
 }
 
-func (s *RouterSuite) TestRouteNotFound(c *check.C) {
+func (s *RouterIntegrationSuite) TestRouteNotFound(c *check.C) {
        token := arvadostest.ActiveTokenV2
        req := (&testReq{
                method: "POST",
@@ -222,7 +330,7 @@ func (s *RouterSuite) TestRouteNotFound(c *check.C) {
        c.Check(j["errors"].([]interface{})[0], check.Equals, "API endpoint not found")
 }
 
-func (s *RouterSuite) TestCORS(c *check.C) {
+func (s *RouterIntegrationSuite) TestCORS(c *check.C) {
        token := arvadostest.ActiveTokenV2
        req := (&testReq{
                method: "OPTIONS",
@@ -270,3 +378,18 @@ func (s *RouterSuite) TestCORS(c *check.C) {
                c.Check(rr.Result().Header.Get("Access-Control-Allow-Headers"), check.Equals, "")
        }
 }
+
+func doRequest(c *check.C, rtr http.Handler, token, method, path string, hdrs http.Header, body io.Reader) (*http.Request, *httptest.ResponseRecorder, map[string]interface{}) {
+       req := httptest.NewRequest(method, path, body)
+       for k, v := range hdrs {
+               req.Header[k] = v
+       }
+       req.Header.Set("Authorization", "Bearer "+token)
+       rr := httptest.NewRecorder()
+       rtr.ServeHTTP(rr, req)
+       c.Logf("response body: %s", rr.Body.String())
+       var jresp map[string]interface{}
+       err := json.Unmarshal(rr.Body.Bytes(), &jresp)
+       c.Check(err, check.IsNil)
+       return req, rr, jresp
+}
diff --git a/sdk/go/arvadostest/api.go b/sdk/go/arvadostest/api.go
new file mode 100644 (file)
index 0000000..a3cacf3
--- /dev/null
@@ -0,0 +1,135 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package arvadostest
+
+import (
+       "context"
+       "errors"
+       "sync"
+
+       "git.curoverse.com/arvados.git/sdk/go/arvados"
+)
+
+var ErrStubUnimplemented = errors.New("stub unimplemented")
+
+type APIStub struct {
+       // The error to return from every stubbed API method.
+       Error error
+       calls []APIStubCall
+       mtx   sync.Mutex
+}
+
+func (as *APIStub) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
+       as.appendCall(as.CollectionCreate, ctx, options)
+       return arvados.Collection{}, as.Error
+}
+func (as *APIStub) CollectionUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Collection, error) {
+       as.appendCall(as.CollectionUpdate, ctx, options)
+       return arvados.Collection{}, as.Error
+}
+func (as *APIStub) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
+       as.appendCall(as.CollectionGet, ctx, options)
+       return arvados.Collection{}, as.Error
+}
+func (as *APIStub) CollectionList(ctx context.Context, options arvados.ListOptions) (arvados.CollectionList, error) {
+       as.appendCall(as.CollectionList, ctx, options)
+       return arvados.CollectionList{}, as.Error
+}
+func (as *APIStub) CollectionProvenance(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
+       as.appendCall(as.CollectionProvenance, ctx, options)
+       return nil, as.Error
+}
+func (as *APIStub) CollectionUsedBy(ctx context.Context, options arvados.GetOptions) (map[string]interface{}, error) {
+       as.appendCall(as.CollectionUsedBy, ctx, options)
+       return nil, as.Error
+}
+func (as *APIStub) CollectionDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
+       as.appendCall(as.CollectionDelete, ctx, options)
+       return arvados.Collection{}, as.Error
+}
+func (as *APIStub) CollectionTrash(ctx context.Context, options arvados.DeleteOptions) (arvados.Collection, error) {
+       as.appendCall(as.CollectionTrash, ctx, options)
+       return arvados.Collection{}, as.Error
+}
+func (as *APIStub) CollectionUntrash(ctx context.Context, options arvados.UntrashOptions) (arvados.Collection, error) {
+       as.appendCall(as.CollectionUntrash, ctx, options)
+       return arvados.Collection{}, as.Error
+}
+func (as *APIStub) ContainerCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Container, error) {
+       as.appendCall(as.ContainerCreate, ctx, options)
+       return arvados.Container{}, as.Error
+}
+func (as *APIStub) ContainerUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Container, error) {
+       as.appendCall(as.ContainerUpdate, ctx, options)
+       return arvados.Container{}, as.Error
+}
+func (as *APIStub) ContainerGet(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
+       as.appendCall(as.ContainerGet, ctx, options)
+       return arvados.Container{}, as.Error
+}
+func (as *APIStub) ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) {
+       as.appendCall(as.ContainerList, ctx, options)
+       return arvados.ContainerList{}, as.Error
+}
+func (as *APIStub) ContainerDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Container, error) {
+       as.appendCall(as.ContainerDelete, ctx, options)
+       return arvados.Container{}, as.Error
+}
+func (as *APIStub) ContainerLock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
+       as.appendCall(as.ContainerLock, ctx, options)
+       return arvados.Container{}, as.Error
+}
+func (as *APIStub) ContainerUnlock(ctx context.Context, options arvados.GetOptions) (arvados.Container, error) {
+       as.appendCall(as.ContainerUnlock, ctx, options)
+       return arvados.Container{}, as.Error
+}
+func (as *APIStub) SpecimenCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Specimen, error) {
+       as.appendCall(as.SpecimenCreate, ctx, options)
+       return arvados.Specimen{}, as.Error
+}
+func (as *APIStub) SpecimenUpdate(ctx context.Context, options arvados.UpdateOptions) (arvados.Specimen, error) {
+       as.appendCall(as.SpecimenUpdate, ctx, options)
+       return arvados.Specimen{}, as.Error
+}
+func (as *APIStub) SpecimenGet(ctx context.Context, options arvados.GetOptions) (arvados.Specimen, error) {
+       as.appendCall(as.SpecimenGet, ctx, options)
+       return arvados.Specimen{}, as.Error
+}
+func (as *APIStub) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) {
+       as.appendCall(as.SpecimenList, ctx, options)
+       return arvados.SpecimenList{}, as.Error
+}
+func (as *APIStub) SpecimenDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Specimen, error) {
+       as.appendCall(as.SpecimenDelete, ctx, options)
+       return arvados.Specimen{}, as.Error
+}
+func (as *APIStub) APIClientAuthorizationCurrent(ctx context.Context, options arvados.GetOptions) (arvados.APIClientAuthorization, error) {
+       as.appendCall(as.APIClientAuthorizationCurrent, ctx, options)
+       return arvados.APIClientAuthorization{}, as.Error
+}
+
+func (as *APIStub) appendCall(method interface{}, ctx context.Context, options interface{}) {
+       as.mtx.Lock()
+       defer as.mtx.Unlock()
+       as.calls = append(as.calls, APIStubCall{method, ctx, options})
+}
+
+func (as *APIStub) Calls(method interface{}) []APIStubCall {
+       as.mtx.Lock()
+       defer as.mtx.Unlock()
+       var calls []APIStubCall
+       for _, call := range as.calls {
+               if method == nil || call.Method == method {
+                       calls = append(calls, call)
+               }
+       }
+       return calls
+}
+
+type APIStubCall struct {
+       Method  interface{}
+       Context context.Context
+       Options interface{}
+}