From 00612edf372483d0cecd23532bf0437df5a1258c Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Wed, 23 Jul 2014 14:36:47 -0300 Subject: [PATCH 1/2] Simplify parameters passing, no need to unpack (re #119) --- repository/repository_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repository/repository_test.go b/repository/repository_test.go index b18823d..b350ed1 100644 --- a/repository/repository_test.go +++ b/repository/repository_test.go @@ -576,7 +576,7 @@ func (s *S) TestGetTreeIntegration(c *gocheck.C) { repo := "gandalf-test-repo" file := "README" content := "much WOW" - cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, []string{"such", "folder", "much", "magic"}...) + cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic") defer func() { cleanUp() bare = oldBare @@ -594,7 +594,7 @@ func (s *S) TestGetTreeIntegrationWithEscapedFileName(c *gocheck.C) { repo := "gandalf-test-repo" file := "such\tREADME" content := "much WOW" - cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, []string{"such", "folder", "much", "magic"}...) + cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic") defer func() { cleanUp() bare = oldBare @@ -612,7 +612,7 @@ func (s *S) TestGetTreeIntegrationWithFileNameWithSpace(c *gocheck.C) { repo := "gandalf-test-repo" file := "much README" content := "much WOW" - cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, []string{"such", "folder", "much", "magic"}...) + cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic") defer func() { cleanUp() bare = oldBare From d654b40dead2be44c812a398066ed722028794de Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Wed, 23 Jul 2014 12:09:36 -0300 Subject: [PATCH 2/2] Allow empty message (no content) when committing --- repository/mocks.go | 2 +- repository/repository_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/repository/mocks.go b/repository/mocks.go index 0187f28..268704a 100644 --- a/repository/mocks.go +++ b/repository/mocks.go @@ -100,7 +100,7 @@ func CreateTestRepository(tmp_path string, repo string, file string, content str if err != nil { return cleanup, err } - cmd = exec.Command(gitPath, "commit", "-m", content) + cmd = exec.Command(gitPath, "commit", "-m", content, "--allow-empty-message") cmd.Dir = testPath err = cmd.Run() return cleanup, err diff --git a/repository/repository_test.go b/repository/repository_test.go index b350ed1..d9ac9f8 100644 --- a/repository/repository_test.go +++ b/repository/repository_test.go @@ -538,6 +538,23 @@ func (s *S) TestGetFileContentIntegration(c *gocheck.C) { c.Assert(string(contents), gocheck.Equals, content) } +func (s *S) TestGetFileContentIntegrationEmptyContent(c *gocheck.C) { + oldBare := bare + bare = "/tmp" + repo := "gandalf-test-repo" + file := "README" + content := "" + cleanUp, errCreate := CreateTestRepository(bare, repo, file, content) + defer func() { + cleanUp() + bare = oldBare + }() + c.Assert(errCreate, gocheck.IsNil) + contents, err := GetFileContents(repo, "master", file) + c.Assert(err, gocheck.IsNil) + c.Assert(string(contents), gocheck.Equals, content) +} + func (s *S) TestGetFileContentWhenRefIsInvalid(c *gocheck.C) { oldBare := bare bare = "/tmp" @@ -588,6 +605,24 @@ func (s *S) TestGetTreeIntegration(c *gocheck.C) { c.Assert(tree[0]["rawPath"], gocheck.Equals, "much/README") } +func (s *S) TestGetTreeIntegrationEmptyContent(c *gocheck.C) { + oldBare := bare + bare = "/tmp" + repo := "gandalf-test-repo" + file := "README" + content := "" + cleanUp, errCreate := CreateTestRepository(bare, repo, file, content, "such", "folder", "much", "magic") + defer func() { + cleanUp() + bare = oldBare + }() + c.Assert(errCreate, gocheck.IsNil) + tree, err := GetTree(repo, "master", "much/README") + c.Assert(err, gocheck.IsNil) + c.Assert(tree[0]["path"], gocheck.Equals, "much/README") + c.Assert(tree[0]["rawPath"], gocheck.Equals, "much/README") +} + func (s *S) TestGetTreeIntegrationWithEscapedFileName(c *gocheck.C) { oldBare := bare bare = "/tmp"