From 3b35cf557f7266797d0aee1d1020e08912fb34c1 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Wed, 18 Jan 2017 16:43:10 +0100 Subject: 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. --- common_test.go | 18 +++++++++++++++--- 1 file 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) -- cgit