aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-05-16 22:16:15 +0200
committerGitHub <noreply@github.com>2017-05-16 22:16:15 +0200
commit0f2abe7da065ed25085ea265db20e77609cefdbc (patch)
treef51f804ba5526e8990d0c1ce186e239667930600 /plumbing
parent681f24d65046397228b4e4bb4e248fdb1e27f347 (diff)
parent7e798fc34d703770e3391de8ecd65edea0d40181 (diff)
downloadgo-git-0f2abe7da065ed25085ea265db20e77609cefdbc.tar.gz
Merge pull request #394 from ajnavarro/fix/endpoints-equality
transport/server: use Endpoint string representation as a map key.
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/transport/server/loader.go4
-rw-r--r--plumbing/transport/server/loader_test.go16
-rw-r--r--plumbing/transport/server/server_test.go4
3 files changed, 20 insertions, 4 deletions
diff --git a/plumbing/transport/server/loader.go b/plumbing/transport/server/loader.go
index b51a795..386c2f0 100644
--- a/plumbing/transport/server/loader.go
+++ b/plumbing/transport/server/loader.go
@@ -44,13 +44,13 @@ func (l *fsLoader) Load(ep transport.Endpoint) (storer.Storer, error) {
// MapLoader is a Loader that uses a lookup map of storer.Storer by
// transport.Endpoint.
-type MapLoader map[transport.Endpoint]storer.Storer
+type MapLoader map[string]storer.Storer
// Load returns a storer.Storer for given a transport.Endpoint by looking it up
// in the map. Returns transport.ErrRepositoryNotFound if the endpoint does not
// exist.
func (l MapLoader) Load(ep transport.Endpoint) (storer.Storer, error) {
- s, ok := l[ep]
+ s, ok := l[ep.String()]
if !ok {
return nil, transport.ErrRepositoryNotFound
}
diff --git a/plumbing/transport/server/loader_test.go b/plumbing/transport/server/loader_test.go
index 5f32cb0..38fabe3 100644
--- a/plumbing/transport/server/loader_test.go
+++ b/plumbing/transport/server/loader_test.go
@@ -5,6 +5,7 @@ import (
"path/filepath"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
+ "gopkg.in/src-d/go-git.v4/storage/memory"
. "gopkg.in/check.v1"
)
@@ -54,3 +55,18 @@ func (s *LoaderSuite) TestLoadIgnoreHost(c *C) {
c.Assert(err, IsNil)
c.Assert(sto, NotNil)
}
+
+func (s *LoaderSuite) TestMapLoader(c *C) {
+ ep, err := transport.NewEndpoint("file://test")
+ sto := memory.NewStorage()
+ c.Assert(err, IsNil)
+
+ loader := MapLoader{ep.String(): sto}
+
+ ep, err = transport.NewEndpoint("file://test")
+ c.Assert(err, IsNil)
+
+ loaderSto, err := loader.Load(ep)
+ c.Assert(err, IsNil)
+ c.Assert(sto, Equals, loaderSto)
+}
diff --git a/plumbing/transport/server/server_test.go b/plumbing/transport/server/server_test.go
index 2459ab2..6a64674 100644
--- a/plumbing/transport/server/server_test.go
+++ b/plumbing/transport/server/server_test.go
@@ -53,14 +53,14 @@ func (s *BaseSuite) prepareRepositories(c *C, basic *transport.Endpoint,
*basic = ep
sto, err := filesystem.NewStorage(fs)
c.Assert(err, IsNil)
- s.loader[ep] = sto
+ s.loader[ep.String()] = sto
path = "/empty.git"
url = fmt.Sprintf("%s://%s", inprocScheme, path)
ep, err = transport.NewEndpoint(url)
c.Assert(err, IsNil)
*empty = ep
- s.loader[ep] = memory.NewStorage()
+ s.loader[ep.String()] = memory.NewStorage()
path = "/non-existent.git"
url = fmt.Sprintf("%s://%s", inprocScheme, path)