X Tutup
Skip to content

Commit 633ccdd

Browse files
committed
remove unused test helper
1 parent 121173c commit 633ccdd

File tree

1 file changed

+0
-62
lines changed

1 file changed

+0
-62
lines changed

test/helpers.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package test
22

3-
import (
4-
"fmt"
5-
"io/ioutil"
6-
"os"
7-
"os/exec"
8-
"path/filepath"
9-
)
10-
113
// OutputStub implements a simple utils.Runnable
124
type OutputStub struct {
135
Out []byte
@@ -20,57 +12,3 @@ func (s OutputStub) Output() ([]byte, error) {
2012
func (s OutputStub) Run() error {
2113
return nil
2214
}
23-
24-
type TempGitRepo struct {
25-
Remote string
26-
TearDown func()
27-
}
28-
29-
func UseTempGitRepo() *TempGitRepo {
30-
pwd, _ := os.Getwd()
31-
oldEnv := make(map[string]string)
32-
overrideEnv := func(name, value string) {
33-
oldEnv[name] = os.Getenv(name)
34-
os.Setenv(name, value)
35-
}
36-
37-
remotePath := filepath.Join(pwd, "..", "test", "fixtures", "test.git")
38-
home, err := ioutil.TempDir("", "test-repo")
39-
if err != nil {
40-
panic(err)
41-
}
42-
43-
overrideEnv("HOME", home)
44-
overrideEnv("XDG_CONFIG_HOME", "")
45-
overrideEnv("XDG_CONFIG_DIRS", "")
46-
47-
targetPath := filepath.Join(home, "test.git")
48-
cmd := exec.Command("git", "clone", remotePath, targetPath)
49-
if output, err := cmd.Output(); err != nil {
50-
panic(fmt.Errorf("error running %s\n%s\n%s", cmd, err, output))
51-
}
52-
53-
if err = os.Chdir(targetPath); err != nil {
54-
panic(err)
55-
}
56-
57-
// Our libs expect the origin to be a github url
58-
cmd = exec.Command("git", "remote", "set-url", "origin", "https://github.com/github/FAKE-GITHUB-REPO-NAME")
59-
if output, err := cmd.Output(); err != nil {
60-
panic(fmt.Errorf("error running %s\n%s\n%s", cmd, err, output))
61-
}
62-
63-
tearDown := func() {
64-
if err := os.Chdir(pwd); err != nil {
65-
panic(err)
66-
}
67-
for name, value := range oldEnv {
68-
os.Setenv(name, value)
69-
}
70-
if err = os.RemoveAll(home); err != nil {
71-
panic(err)
72-
}
73-
}
74-
75-
return &TempGitRepo{Remote: remotePath, TearDown: tearDown}
76-
}

0 commit comments

Comments
 (0)
X Tutup