aboutsummaryrefslogblamecommitdiffstats
path: root/plumbing/transport/file/common_test.go
blob: 3dc4500b46ef60d50171bbce093463b6f6a32c18 (plain) (tree)
1
2
3
4
5
6
7
8
9


            
            

                       
 
                                          
 
                             
                   

 




                             
 
                             
 

                                        
 

                                                                      

         









                                                                    
 
package file

import (
	"os"
	"os/exec"
	"path/filepath"

	"github.com/src-d/go-git-fixtures"

	. "gopkg.in/check.v1"
	"io/ioutil"
)

type CommonSuite struct {
	fixtures.Suite
	ReceivePackBin string
	UploadPackBin  string
}

var _ = Suite(&CommonSuite{})

func (s *CommonSuite) SetUpSuite(c *C) {
	s.Suite.SetUpSuite(c)

	if err := exec.Command("git", "--version").Run(); err != nil {
		c.Skip("git command not found")
	}

	binDir, err := ioutil.TempDir(os.TempDir(), "")
	c.Assert(err, IsNil)
	s.ReceivePackBin = filepath.Join(binDir, "git-receive-pack")
	s.UploadPackBin = filepath.Join(binDir, "git-upload-pack")
	bin := filepath.Join(binDir, "go-git")
	cmd := exec.Command("go", "build", "-o", bin,
		"../../../cli/go-git/...")
	c.Assert(cmd.Run(), IsNil)
	c.Assert(os.Symlink(bin, s.ReceivePackBin), IsNil)
	c.Assert(os.Symlink(bin, s.UploadPackBin), IsNil)
}