X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0561bd0c3c07257fd58ded6c7cfa5feeae97af57..b3a016e9a47d453b5ae4d287d8b6eaafd69971df:/sdk/go/arvadostest/stub.go diff --git a/sdk/go/arvadostest/stub.go b/sdk/go/arvadostest/stub.go index 89925a957d..80735f86eb 100644 --- a/sdk/go/arvadostest/stub.go +++ b/sdk/go/arvadostest/stub.go @@ -6,6 +6,9 @@ package arvadostest import ( "net/http" + "net/url" + + "git.curoverse.com/arvados.git/sdk/go/arvados" ) // StubResponse struct with response status and body @@ -37,3 +40,22 @@ func (stub *ServerStub) ServeHTTP(resp http.ResponseWriter, req *http.Request) { resp.Write([]byte(``)) } } + +// SetServiceURL overrides the given service config/discovery with the +// given internalURLs. +// +// ExternalURL is set to the last internalURL, which only aims to +// address the case where there is only one. +// +// SetServiceURL panics on errors. +func SetServiceURL(service *arvados.Service, internalURLs ...string) { + service.InternalURLs = map[arvados.URL]arvados.ServiceInstance{} + for _, u := range internalURLs { + u, err := url.Parse(u) + if err != nil { + panic(err) + } + service.InternalURLs[arvados.URL(*u)] = arvados.ServiceInstance{} + service.ExternalURL = arvados.URL(*u) + } +}