Add a repo.GitCmd, tidy up ls-files test
This commit is contained in:
parent
67e8f72f77
commit
11128a86d2
@ -108,6 +108,10 @@ func (r *Repository) MediaCmd(args ...string) string {
|
||||
return r.cmd(Bin, args...)
|
||||
}
|
||||
|
||||
func (r *Repository) GitCmd(args ...string) string {
|
||||
return r.cmd("git", args...)
|
||||
}
|
||||
|
||||
func (r *Repository) Test() {
|
||||
for _, path := range r.Paths {
|
||||
r.test(path)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
@ -11,14 +10,20 @@ func TestLsFiles(t *testing.T) {
|
||||
defer repo.Test()
|
||||
|
||||
cmd := repo.Command("ls-files")
|
||||
cmd.Output = "somefile"
|
||||
cmd.Output = "a.dat"
|
||||
|
||||
cmd.Before(func() {
|
||||
// Add a link file
|
||||
dir := filepath.Join(repo.Path, ".git", "media", "objects", "48")
|
||||
os.MkdirAll(dir, 0755)
|
||||
path := filepath.Join(".git", "info", "attributes")
|
||||
repo.WriteFile(path, "*.dat filter=media -crlf\n")
|
||||
|
||||
path := filepath.Join(dir, "baff6546c517fcd41b98413bb2b0bcbb8d6505")
|
||||
repo.WriteFile(path, "oid f712374589a4f37f0fd6b941a104c7ccf43f68b1fdecb4d5cd88b80acbf98fc2\nname somefile")
|
||||
// Add a git media file
|
||||
repo.WriteFile(filepath.Join(repo.Path, "a.dat"), "some data")
|
||||
repo.GitCmd("add", "a.dat")
|
||||
repo.GitCmd("commit", "-m", "a")
|
||||
|
||||
// Add a regular file
|
||||
repo.WriteFile(filepath.Join(repo.Path, "hi.txt"), "some text")
|
||||
repo.GitCmd("add", "hi.txt")
|
||||
repo.GitCmd("commit", "-m", "hi")
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user