From 633ccddb7ad41fb51d381164ad36b45abb820ad2 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 23 Mar 2020 15:58:18 -0500 Subject: [PATCH] remove unused test helper --- test/helpers.go | 62 ------------------------------------------------- 1 file changed, 62 deletions(-) diff --git a/test/helpers.go b/test/helpers.go index 6bcfcadca..add7b90c3 100644 --- a/test/helpers.go +++ b/test/helpers.go @@ -1,13 +1,5 @@ package test -import ( - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" -) - // OutputStub implements a simple utils.Runnable type OutputStub struct { Out []byte @@ -20,57 +12,3 @@ func (s OutputStub) Output() ([]byte, error) { func (s OutputStub) Run() error { return nil } - -type TempGitRepo struct { - Remote string - TearDown func() -} - -func UseTempGitRepo() *TempGitRepo { - pwd, _ := os.Getwd() - oldEnv := make(map[string]string) - overrideEnv := func(name, value string) { - oldEnv[name] = os.Getenv(name) - os.Setenv(name, value) - } - - remotePath := filepath.Join(pwd, "..", "test", "fixtures", "test.git") - home, err := ioutil.TempDir("", "test-repo") - if err != nil { - panic(err) - } - - overrideEnv("HOME", home) - overrideEnv("XDG_CONFIG_HOME", "") - overrideEnv("XDG_CONFIG_DIRS", "") - - targetPath := filepath.Join(home, "test.git") - cmd := exec.Command("git", "clone", remotePath, targetPath) - if output, err := cmd.Output(); err != nil { - panic(fmt.Errorf("error running %s\n%s\n%s", cmd, err, output)) - } - - if err = os.Chdir(targetPath); err != nil { - panic(err) - } - - // Our libs expect the origin to be a github url - cmd = exec.Command("git", "remote", "set-url", "origin", "https://github.com/github/FAKE-GITHUB-REPO-NAME") - if output, err := cmd.Output(); err != nil { - panic(fmt.Errorf("error running %s\n%s\n%s", cmd, err, output)) - } - - tearDown := func() { - if err := os.Chdir(pwd); err != nil { - panic(err) - } - for name, value := range oldEnv { - os.Setenv(name, value) - } - if err = os.RemoveAll(home); err != nil { - panic(err) - } - } - - return &TempGitRepo{Remote: remotePath, TearDown: tearDown} -}