Fix Rails package version calculation again.
[arvados.git] / sdk / go / arvadostest / stub.go
index 15a0254135894d65e200acad59432453c717a0ea..80735f86eb613d86d3b57f0a41af3813de6d6aa1 100644 (file)
@@ -1,7 +1,14 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package arvadostest
 
 import (
        "net/http"
+       "net/url"
+
+       "git.curoverse.com/arvados.git/sdk/go/arvados"
 )
 
 // StubResponse struct with response status and body
@@ -33,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)
+       }
+}