2014-06-04 17:40:09 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2014-06-05 23:13:42 +00:00
|
|
|
"os/exec"
|
2014-06-04 17:40:09 +00:00
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2014-06-05 16:52:32 +00:00
|
|
|
func TestEnv(t *testing.T) {
|
2014-06-04 17:40:09 +00:00
|
|
|
repo := NewRepository(t, "empty")
|
2014-06-04 18:57:20 +00:00
|
|
|
defer repo.Test()
|
|
|
|
|
2014-06-04 17:44:07 +00:00
|
|
|
repo.AddPath(repo.Path, ".git")
|
|
|
|
repo.AddPath(repo.Path, "subdir")
|
2014-06-04 17:40:09 +00:00
|
|
|
|
2014-06-05 16:52:32 +00:00
|
|
|
cmd := repo.Command("env")
|
2014-06-04 17:40:09 +00:00
|
|
|
SetConfigOutput(cmd, map[string]string{
|
2015-03-19 20:18:31 +00:00
|
|
|
"Endpoint": "https://example.com/git/lfs.git/info/lfs",
|
2014-06-04 17:40:09 +00:00
|
|
|
"LocalWorkingDir": repo.Path,
|
|
|
|
"LocalGitDir": filepath.Join(repo.Path, ".git"),
|
2015-03-19 19:30:55 +00:00
|
|
|
"LocalMediaDir": filepath.Join(repo.Path, ".git", "lfs", "objects"),
|
|
|
|
"TempDir": filepath.Join(repo.Path, ".git", "lfs", "tmp"),
|
2014-06-04 17:40:09 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-06-05 16:52:32 +00:00
|
|
|
func TestEnvWithMediaUrl(t *testing.T) {
|
2014-06-04 17:40:09 +00:00
|
|
|
repo := NewRepository(t, "config_media_url")
|
2014-06-04 18:57:20 +00:00
|
|
|
defer repo.Test()
|
2014-06-04 17:40:09 +00:00
|
|
|
|
2014-06-05 16:52:32 +00:00
|
|
|
cmd := repo.Command("env")
|
2014-06-04 17:40:09 +00:00
|
|
|
SetConfigOutput(cmd, map[string]string{
|
|
|
|
"Endpoint": "http://foo/bar",
|
|
|
|
"LocalWorkingDir": repo.Path,
|
|
|
|
"LocalGitDir": filepath.Join(repo.Path, ".git"),
|
2015-03-19 19:30:55 +00:00
|
|
|
"LocalMediaDir": filepath.Join(repo.Path, ".git", "lfs", "objects"),
|
|
|
|
"TempDir": filepath.Join(repo.Path, ".git", "lfs", "tmp"),
|
2014-06-04 17:40:09 +00:00
|
|
|
})
|
|
|
|
}
|
2014-06-05 23:13:42 +00:00
|
|
|
|
|
|
|
func TestEnvWithSubmoduleFromRepository(t *testing.T) {
|
|
|
|
repo := NewRepository(t, "submodule")
|
|
|
|
defer repo.Test()
|
|
|
|
|
|
|
|
cmd := repo.Command("env")
|
|
|
|
SetConfigOutput(cmd, map[string]string{
|
2015-03-19 20:18:31 +00:00
|
|
|
"Endpoint": "https://example.com/git/lfs.git/info/lfs",
|
2014-06-05 23:13:42 +00:00
|
|
|
"LocalWorkingDir": repo.Path,
|
|
|
|
"LocalGitDir": filepath.Join(repo.Path, ".git"),
|
2015-03-19 19:30:55 +00:00
|
|
|
"LocalMediaDir": filepath.Join(repo.Path, ".git", "lfs", "objects"),
|
|
|
|
"TempDir": filepath.Join(repo.Path, ".git", "lfs", "tmp"),
|
2014-06-05 23:13:42 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
cmd.Before(func() {
|
|
|
|
submodPath := filepath.Join(Root, "commands", "repos", "attributes.git")
|
|
|
|
exec.Command("git", "config", "--add", "submodule.attributes.url", submodPath).Run()
|
|
|
|
exec.Command("git", "submodule", "update").Run()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestEnvWithSubmoduleFromSubmodule(t *testing.T) {
|
|
|
|
repo := NewRepository(t, "submodule")
|
|
|
|
defer repo.Test()
|
|
|
|
|
2014-06-13 19:23:44 +00:00
|
|
|
repo.AddPath(repo.Path, "attributes")
|
2014-06-05 23:13:42 +00:00
|
|
|
repo.Paths = repo.Paths[1:]
|
|
|
|
|
|
|
|
cmd := repo.Command("env")
|
|
|
|
cmd.Before(func() {
|
|
|
|
submodPath := filepath.Join(Root, "commands", "repos", "attributes.git")
|
|
|
|
exec.Command("git", "config", "--add", "submodule.attributes.url", submodPath).Run()
|
|
|
|
exec.Command("git", "submodule", "update").Run()
|
2014-06-13 19:23:44 +00:00
|
|
|
os.Chdir(filepath.Join("attributes"))
|
2014-06-05 23:13:42 +00:00
|
|
|
exec.Command("git", "checkout", "-b", "whatevs").Run()
|
|
|
|
})
|
|
|
|
}
|
2014-06-13 18:45:41 +00:00
|
|
|
|
|
|
|
func TestEnvWithConfiguredSubmodule(t *testing.T) {
|
|
|
|
repo := NewRepository(t, "submodule")
|
|
|
|
defer repo.Test()
|
|
|
|
|
|
|
|
repo.AddPath(repo.Path, "config_media_url")
|
|
|
|
repo.Paths = repo.Paths[1:]
|
|
|
|
|
|
|
|
cmd := repo.Command("env")
|
2014-06-16 15:26:01 +00:00
|
|
|
|
2014-06-13 18:45:41 +00:00
|
|
|
SetConfigOutput(cmd, map[string]string{
|
|
|
|
"Endpoint": "http://foo/bar",
|
|
|
|
"LocalWorkingDir": filepath.Join(repo.Path, "config_media_url"),
|
2014-06-16 15:26:01 +00:00
|
|
|
"LocalGitDir": filepath.Join(repo.Path, ".git", "modules", "config_media_url"),
|
2015-03-19 19:30:55 +00:00
|
|
|
"LocalMediaDir": filepath.Join(repo.Path, ".git", "modules", "config_media_url", "lfs", "objects"),
|
|
|
|
"TempDir": filepath.Join(repo.Path, ".git", "modules", "config_media_url", "lfs", "tmp"),
|
2014-06-13 18:45:41 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
cmd.Before(func() {
|
|
|
|
submodPath := filepath.Join(Root, "commands", "repos", "config_media_url.git")
|
|
|
|
exec.Command("git", "submodule", "add", submodPath).Run()
|
|
|
|
exec.Command("git", "submodule", "update").Run()
|
|
|
|
os.Chdir("config_media_url")
|
|
|
|
exec.Command("git", "checkout", "-b", "whatevs").Run()
|
|
|
|
})
|
|
|
|
}
|