From b15ebe585a6d913c90f43b1f8e2c2ab646ecf96a Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Wed, 13 Aug 2014 19:23:03 -0300 Subject: [PATCH] Set `repository:tempDir` as not mandatory (re #140) --- repository/repository.go | 9 ++------- repository/repository_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/repository/repository.go b/repository/repository.go index 5823d39..370d17b 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -26,13 +26,8 @@ import ( var tempDir string func tempDirLocation() string { - if tempDir != "" { - return tempDir - } - var err error - tempDir, err = config.GetString("repository:tempDir") - if err != nil { - panic("You should configure a repository:tempDir for gandalf.") + if tempDir == "" { + tempDir, _ = config.GetString("repository:tempDir") } return tempDir } diff --git a/repository/repository_test.go b/repository/repository_test.go index 9a0faec..52e5d89 100644 --- a/repository/repository_test.go +++ b/repository/repository_test.go @@ -70,6 +70,16 @@ func (s *S) TestTempDirLocationDontResetTempDir(c *gocheck.C) { c.Assert(tempDirLocation(), gocheck.Equals, "/var/folders") } +func (s *S) TestTempDirLocationWhenNotInGandalfConf(c *gocheck.C) { + config.Unset("repository:tempDir") + oldTempDir := tempDir + tempDir = "" + defer func() { + tempDir = oldTempDir + }() + c.Assert(tempDirLocation(), gocheck.Equals, "") +} + func (s *S) TestNewShouldCreateANewRepository(c *gocheck.C) { tmpdir, err := commandmocker.Add("git", "$*") c.Assert(err, gocheck.IsNil)