github.com/q2/git-lfs@v0.5.1-0.20150410234700-03a0d4cec40e/commands/push_test.go (about)

     1  package commands
     2  
     3  import (
     4  	"path/filepath"
     5  	"testing"
     6  )
     7  
     8  func TestPushWithEmptyQueue(t *testing.T) {
     9  	repo := NewRepository(t, "empty")
    10  	defer repo.Test()
    11  
    12  	cmd := repo.Command("push", "origin", "master")
    13  	cmd.Output = ""
    14  }
    15  
    16  func TestPushToMaster(t *testing.T) {
    17  	repo := NewRepository(t, "empty")
    18  	defer repo.Test()
    19  
    20  	cmd := repo.Command("push", "--dry-run", "origin", "master")
    21  	cmd.Output = "push a.dat"
    22  
    23  	cmd.Before(func() {
    24  		repo.GitCmd("remote", "remove", "origin")
    25  
    26  		originPath := filepath.Join(Root, "commands", "repos", "empty.git")
    27  		repo.GitCmd("remote", "add", "origin", originPath)
    28  
    29  		repo.GitCmd("fetch")
    30  
    31  		repo.WriteFile(filepath.Join(repo.Path, ".gitattributes"), "*.dat filter=lfs -crlf\n")
    32  
    33  		// Add a Git LFS file
    34  		repo.WriteFile(filepath.Join(repo.Path, "a.dat"), "some data")
    35  		repo.GitCmd("add", "a.dat")
    36  		repo.GitCmd("commit", "-m", "a")
    37  	})
    38  }
    39  
    40  func TestPushToNewBranch(t *testing.T) {
    41  	repo := NewRepository(t, "empty")
    42  	defer repo.Test()
    43  
    44  	cmd := repo.Command("push", "--dry-run", "origin", "newbranch")
    45  	cmd.Output = "push a.dat\npush b.dat"
    46  
    47  	cmd.Before(func() {
    48  		repo.GitCmd("remote", "remove", "origin")
    49  
    50  		originPath := filepath.Join(Root, "commands", "repos", "empty.git")
    51  		repo.GitCmd("remote", "add", "origin", originPath)
    52  
    53  		repo.GitCmd("fetch")
    54  
    55  		repo.WriteFile(filepath.Join(repo.Path, ".gitattributes"), "*.dat filter=lfs -crlf\n")
    56  		repo.GitCmd("add", ".gitattributes")
    57  		repo.GitCmd("commit", "-m", "attributes")
    58  
    59  		// Add a Git LFS file
    60  		repo.WriteFile(filepath.Join(repo.Path, "a.dat"), "some data")
    61  		repo.GitCmd("add", "a.dat")
    62  		repo.GitCmd("commit", "-m", "a")
    63  
    64  		// Branch off
    65  		repo.GitCmd("checkout", "-b", "newbranch")
    66  
    67  		repo.WriteFile(filepath.Join(repo.Path, "b.dat"), "some more data")
    68  		repo.GitCmd("add", "b.dat")
    69  		repo.GitCmd("commit", "-m", "b")
    70  	})
    71  
    72  }