blob: ab03ca0f53750a92f5fbb5a284e84bb2224b29b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package server_test
import (
"testing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/go-git/go-git/v5/plumbing/transport/client"
"github.com/go-git/go-git/v5/plumbing/transport/server"
"github.com/go-git/go-git/v5/plumbing/transport/test"
"github.com/go-git/go-git/v5/storage/filesystem"
"github.com/go-git/go-git/v5/storage/memory"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git-fixtures.v3"
)
func Test(t *testing.T) { TestingT(t) }
type BaseSuite struct {
fixtures.Suite
test.ReceivePackSuite
loader server.MapLoader
client transport.Transport
clientBackup transport.Transport
asClient bool
}
func (s *BaseSuite) SetUpSuite(c *C) {
s.Suite.SetUpSuite(c)
s.loader = server.MapLoader{}
if s.asClient {
s.client = server.NewClient(s.loader)
} else {
s.client = server.NewServer(s.loader)
}
s.clientBackup = client.Protocols["file"]
client.Protocols["file"] = s.client
}
func (s *BaseSuite) TearDownSuite(c *C) {
if s.clientBackup == nil {
delete(client.Protocols, "file")
} else {
client.Protocols["file"] = s.clientBackup
}
}
func (s *BaseSuite) prepareRepositories(c *C) {
var err error
fs := fixtures.Basic().One().DotGit()
s.Endpoint, err = transport.NewEndpoint(fs.Root())
c.Assert(err, IsNil)
s.loader[s.Endpoint.String()] = filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
s.EmptyEndpoint, err = transport.NewEndpoint("/empty.git")
c.Assert(err, IsNil)
s.loader[s.EmptyEndpoint.String()] = memory.NewStorage()
s.NonExistentEndpoint, err = transport.NewEndpoint("/non-existent.git")
c.Assert(err, IsNil)
}
|