Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 3b35cf5

Browse files
smolamcuadros
authored andcommitted
test: restore default protocol. (#215)
BaseSuite sets the https protocol to nil. This can affect other unrelated suites. This commit changes BaseSuite to restore the https protocol during the tear down phase.
1 parent 6593c75 commit 3b35cf5

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

common_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"gopkg.in/src-d/go-git.v4/fixtures"
88
"gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
99
"gopkg.in/src-d/go-git.v4/plumbing/storer"
10+
"gopkg.in/src-d/go-git.v4/plumbing/transport"
1011
"gopkg.in/src-d/go-git.v4/plumbing/transport/client"
1112

1213
. "gopkg.in/check.v1"
@@ -19,17 +20,23 @@ type BaseSuite struct {
1920
Repository *Repository
2021
Storer storer.EncodedObjectStorer
2122

22-
cache map[string]*Repository
23+
backupProtocol transport.Transport
24+
cache map[string]*Repository
2325
}
2426

2527
func (s *BaseSuite) SetUpSuite(c *C) {
2628
s.Suite.SetUpSuite(c)
27-
s.installMockProtocol(c)
29+
s.installMockProtocol()
2830
s.buildBasicRepository(c)
2931

3032
s.cache = make(map[string]*Repository, 0)
3133
}
3234

35+
func (s *BaseSuite) TearDownSuite(c *C) {
36+
s.Suite.TearDownSuite(c)
37+
s.uninstallMockProtocol()
38+
}
39+
3340
func (s *BaseSuite) buildBasicRepository(c *C) {
3441
f := fixtures.Basic().One()
3542
s.Repository = s.NewRepository(f)
@@ -71,10 +78,15 @@ func (s *BaseSuite) NewRepositoryFromPackfile(f *fixtures.Fixture) *Repository {
7178
return r
7279
}
7380

74-
func (s *BaseSuite) installMockProtocol(c *C) {
81+
func (s *BaseSuite) installMockProtocol() {
82+
s.backupProtocol = client.Protocols["https"]
7583
client.InstallProtocol("https", nil)
7684
}
7785

86+
func (s *BaseSuite) uninstallMockProtocol() {
87+
client.InstallProtocol("https", s.backupProtocol)
88+
}
89+
7890
func (s *BaseSuite) GetBasicLocalRepositoryURL() string {
7991
fixture := fixtures.Basic().One()
8092
return s.GetLocalRepositoryURL(fixture)

0 commit comments

Comments
 (0)