aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-01-18 16:43:10 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-01-18 16:43:10 +0100
commit3b35cf557f7266797d0aee1d1020e08912fb34c1 (patch)
tree769929a8767b0e444fa7b6a092fcf44b8dbc79d4
parent6593c757346f9817a770ff0ea091cce3e8243070 (diff)
downloadgo-git-3b35cf557f7266797d0aee1d1020e08912fb34c1.tar.gz
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.
-rw-r--r--common_test.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/common_test.go b/common_test.go
index 980c191..032fdfa 100644
--- a/common_test.go
+++ b/common_test.go
@@ -7,6 +7,7 @@ import (
"gopkg.in/src-d/go-git.v4/fixtures"
"gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
+ "gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/plumbing/transport/client"
. "gopkg.in/check.v1"
@@ -19,17 +20,23 @@ type BaseSuite struct {
Repository *Repository
Storer storer.EncodedObjectStorer
- cache map[string]*Repository
+ backupProtocol transport.Transport
+ cache map[string]*Repository
}
func (s *BaseSuite) SetUpSuite(c *C) {
s.Suite.SetUpSuite(c)
- s.installMockProtocol(c)
+ s.installMockProtocol()
s.buildBasicRepository(c)
s.cache = make(map[string]*Repository, 0)
}
+func (s *BaseSuite) TearDownSuite(c *C) {
+ s.Suite.TearDownSuite(c)
+ s.uninstallMockProtocol()
+}
+
func (s *BaseSuite) buildBasicRepository(c *C) {
f := fixtures.Basic().One()
s.Repository = s.NewRepository(f)
@@ -71,10 +78,15 @@ func (s *BaseSuite) NewRepositoryFromPackfile(f *fixtures.Fixture) *Repository {
return r
}
-func (s *BaseSuite) installMockProtocol(c *C) {
+func (s *BaseSuite) installMockProtocol() {
+ s.backupProtocol = client.Protocols["https"]
client.InstallProtocol("https", nil)
}
+func (s *BaseSuite) uninstallMockProtocol() {
+ client.InstallProtocol("https", s.backupProtocol)
+}
+
func (s *BaseSuite) GetBasicLocalRepositoryURL() string {
fixture := fixtures.Basic().One()
return s.GetLocalRepositoryURL(fixture)