Skip to content

Commit 4876222

Browse files
committed
Test cleanup
1 parent 153061e commit 4876222

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

project/project_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ import (
1212
)
1313

1414
func TestInitialize(t *testing.T) {
15-
d, err := ioutil.TempDir("", "gtm")
15+
rootPath, err := ioutil.TempDir("", "gtm")
1616
if err != nil {
17-
t.Fatalf("Unable to create tempory directory %s, %s", d, err)
17+
t.Fatalf("Unable to create tempory directory %s, %s", rootPath, err)
1818
}
1919
defer func() {
20-
if err = os.RemoveAll(d); err != nil {
21-
fmt.Printf("Error removing %s dir, %s", d, err)
20+
if err = os.RemoveAll(rootPath); err != nil {
21+
fmt.Printf("Error removing %s dir, %s", rootPath, err)
2222
}
2323
}()
2424

2525
savedCurDir, _ := os.Getwd()
26-
if err := os.Chdir(d); err != nil {
26+
if err := os.Chdir(rootPath); err != nil {
2727
t.Fatalf("Unable to change working directory, %s", err)
2828
}
2929
defer func() {
@@ -47,7 +47,7 @@ func TestInitialize(t *testing.T) {
4747
}
4848

4949
for hook, command := range GitHooks {
50-
fp := filepath.Join(d, ".git", "hooks", hook)
50+
fp := filepath.Join(rootPath, ".git", "hooks", hook)
5151
if _, err := os.Stat(fp); os.IsNotExist(err) {
5252
t.Errorf("Initialize(), want file post-commit, got %s", err)
5353
}
@@ -71,7 +71,7 @@ func TestInitialize(t *testing.T) {
7171
}
7272
}
7373

74-
fp := filepath.Join(d, ".gitignore")
74+
fp := filepath.Join(rootPath, ".gitignore")
7575
if _, err := os.Stat(fp); os.IsNotExist(err) {
7676
t.Errorf("Initialize(), want file .gitignore, got %s", err)
7777
}
@@ -84,18 +84,18 @@ func TestInitialize(t *testing.T) {
8484
}
8585

8686
func TestUninitialize(t *testing.T) {
87-
d, err := ioutil.TempDir("", "gtm")
87+
rootPath, err := ioutil.TempDir("", "gtm")
8888
if err != nil {
89-
t.Fatalf("Unable to create tempory directory %s, %s", d, err)
89+
t.Fatalf("Unable to create tempory directory %s, %s", rootPath, err)
9090
}
9191
defer func() {
92-
if err = os.RemoveAll(d); err != nil {
93-
fmt.Printf("Error removing %s dir, %s", d, err)
92+
if err = os.RemoveAll(rootPath); err != nil {
93+
fmt.Printf("Error removing %s dir, %s", rootPath, err)
9494
}
9595
}()
9696

9797
savedCurDir, _ := os.Getwd()
98-
if err := os.Chdir(d); err != nil {
98+
if err := os.Chdir(rootPath); err != nil {
9999
t.Fatalf("Unable to change working directory, %s", err)
100100
}
101101
defer func() {
@@ -124,7 +124,7 @@ func TestUninitialize(t *testing.T) {
124124
}
125125

126126
for hook, command := range GitHooks {
127-
fp := filepath.Join(d, ".git", "hooks", hook)
127+
fp := filepath.Join(rootPath, ".git", "hooks", hook)
128128
if b, err = ioutil.ReadFile(fp); err != nil {
129129
t.Fatalf("Uninitialize(), want error nil, got %s", err)
130130
}
@@ -145,32 +145,32 @@ func TestUninitialize(t *testing.T) {
145145
}
146146
}
147147

148-
fp := filepath.Join(d, ".gitignore")
148+
fp := filepath.Join(rootPath, ".gitignore")
149149
if b, err = ioutil.ReadFile(fp); err != nil {
150150
t.Fatalf("Uninitialize(), want error nil, got %s", err)
151151
}
152152
if strings.Contains(string(b), GitIgnore+"\n") {
153153
t.Errorf("Uninitialize(), do not want %s got %s", GitIgnore, string(b))
154154
}
155155

156-
if _, err := os.Stat(path.Join(d, ".gtm")); !os.IsNotExist(err) {
156+
if _, err := os.Stat(path.Join(rootPath, ".gtm")); !os.IsNotExist(err) {
157157
t.Errorf("Uninitialize(), error directory .gtm exists")
158158
}
159159
}
160160

161161
func TestClean(t *testing.T) {
162-
d, err := ioutil.TempDir("", "gtm")
162+
rootPath, err := ioutil.TempDir("", "gtm")
163163
if err != nil {
164-
t.Fatalf("Unable to create tempory directory %s, %s", d, err)
164+
t.Fatalf("Unable to create tempory directory %s, %s", rootPath, err)
165165
}
166166
defer func() {
167-
if err = os.RemoveAll(d); err != nil {
168-
fmt.Printf("Error removing %s dir, %s", d, err)
167+
if err = os.RemoveAll(rootPath); err != nil {
168+
fmt.Printf("Error removing %s dir, %s", rootPath, err)
169169
}
170170
}()
171171

172172
savedCurDir, _ := os.Getwd()
173-
if err := os.Chdir(d); err != nil {
173+
if err := os.Chdir(rootPath); err != nil {
174174
t.Fatalf("Unable to change working directory, %s", err)
175175
}
176176
defer func() {
@@ -190,7 +190,7 @@ func TestClean(t *testing.T) {
190190
t.Fatalf("Want error nil got error %s", err)
191191
}
192192

193-
gtmPath := filepath.Join(d, GTMDir)
193+
gtmPath := filepath.Join(rootPath, GTMDir)
194194
if _, err := os.Stat(gtmPath); os.IsNotExist(err) {
195195
t.Fatalf("%s directory not found", gtmPath)
196196
}

0 commit comments

Comments
 (0)