aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/server/server_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-01-04 11:18:41 +0100
committerGitHub <noreply@github.com>2017-01-04 11:18:41 +0100
commit841abfb7dc640755c443432064252907e3e55c95 (patch)
tree8af69dcd3b301a10a3e493e2cd805cdec6dcaecd /plumbing/transport/server/server_test.go
parent90d67bb648ae32d5b1a0f7b1af011da6dfb24315 (diff)
downloadgo-git-841abfb7dc640755c443432064252907e3e55c95.tar.gz
server: add git server implementation (#190)
* server: add generic server implementation (transport-independent), both for git-upload-pack and git-receive-pack. * server: move internal functions to internal/common. * cli: add git-receive-pack and git-upload-pack implementations. * format/packfile: add UpdateObjectStorage function, extracted from Remote. * transport: implement tranport RPC-like, only with git-upload-pack and git-receive-pack methods. Client renamed to Transport. * storer: add storer.Storer interface. * protocol/packp: add UploadPackResponse constructor with packfile. * protocol/packp: fix UploadPackResponse encoding, add tests. * protocol/packp/capability: implement All.
Diffstat (limited to 'plumbing/transport/server/server_test.go')
-rw-r--r--plumbing/transport/server/server_test.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/plumbing/transport/server/server_test.go b/plumbing/transport/server/server_test.go
new file mode 100644
index 0000000..2020fe3
--- /dev/null
+++ b/plumbing/transport/server/server_test.go
@@ -0,0 +1,70 @@
+package server_test
+
+import (
+ "fmt"
+ "testing"
+
+ "gopkg.in/src-d/go-git.v4/fixtures"
+ "gopkg.in/src-d/go-git.v4/plumbing/transport"
+ "gopkg.in/src-d/go-git.v4/plumbing/transport/client"
+ "gopkg.in/src-d/go-git.v4/plumbing/transport/server"
+ "gopkg.in/src-d/go-git.v4/storage/filesystem"
+ "gopkg.in/src-d/go-git.v4/storage/memory"
+
+ . "gopkg.in/check.v1"
+)
+
+func Test(t *testing.T) { TestingT(t) }
+
+const inprocScheme = "inproc"
+
+type BaseSuite struct {
+ fixtures.Suite
+ loader server.MapLoader
+ client transport.Transport
+ clientBackup transport.Transport
+}
+
+func (s *BaseSuite) SetUpSuite(c *C) {
+ s.Suite.SetUpSuite(c)
+ s.loader = server.MapLoader{}
+ s.client = server.NewServer(s.loader)
+ s.clientBackup = client.Protocols[inprocScheme]
+ client.Protocols[inprocScheme] = s.client
+}
+
+func (s *BaseSuite) TearDownSuite(c *C) {
+ if s.clientBackup == nil {
+ delete(client.Protocols, inprocScheme)
+ } else {
+ client.Protocols[inprocScheme] = s.clientBackup
+ }
+}
+
+func (s *BaseSuite) prepareRepositories(c *C, basic *transport.Endpoint,
+ empty *transport.Endpoint, nonExistent *transport.Endpoint) {
+
+ f := fixtures.Basic().One()
+ fs := f.DotGit()
+ path := fs.Base()
+ url := fmt.Sprintf("%s://%s", inprocScheme, path)
+ ep, err := transport.NewEndpoint(url)
+ c.Assert(err, IsNil)
+ *basic = ep
+ sto, err := filesystem.NewStorage(fs)
+ c.Assert(err, IsNil)
+ s.loader[ep] = 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()
+
+ path = "/non-existent.git"
+ url = fmt.Sprintf("%s://%s", inprocScheme, path)
+ ep, err = transport.NewEndpoint(url)
+ c.Assert(err, IsNil)
+ *nonExistent = ep
+}