From 11128a86d24b5f9175b80957044c5d715ce3e9ee Mon Sep 17 00:00:00 2001 From: rubyist Date: Mon, 29 Sep 2014 11:41:51 -0400 Subject: [PATCH] Add a repo.GitCmd, tidy up ls-files test --- commands/commands_test.go | 4 ++++ commands/ls_files_test.go | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/commands/commands_test.go b/commands/commands_test.go index 1c8113b2..c1f94caa 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -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) diff --git a/commands/ls_files_test.go b/commands/ls_files_test.go index 13130552..f63064a0 100644 --- a/commands/ls_files_test.go +++ b/commands/ls_files_test.go @@ -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") }) }