1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
11 check "gopkg.in/check.v1"
14 // a Gocheck checker for testing the name of a function. Used with
15 // (*arvadostest.APIStub).Calls() to check that an HTTP request has
16 // been routed to the correct arvados.API method.
18 // c.Check(bytes.NewBuffer().Read, isMethodNamed, "Read")
19 var isMethodNamed check.Checker = &chkIsMethodNamed{
20 CheckerInfo: &check.CheckerInfo{
21 Name: "isMethodNamed",
22 Params: []string{"obtained", "expected"},
26 type chkIsMethodNamed struct{ *check.CheckerInfo }
28 func (*chkIsMethodNamed) Check(params []interface{}, names []string) (bool, string) {
29 methodName := runtime.FuncForPC(reflect.ValueOf(params[0]).Pointer()).Name()
30 regex := `.*\)\.` + params[1].(string) + `(-.*)?`
31 return check.Matches.Check([]interface{}{methodName, regex}, names)