Skip to content

Commit 61be7b6

Browse files
committed
Use os.Link function to link path in integration tests
1 parent a3eb82f commit 61be7b6

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

utils.go

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,10 @@ func readFile(file string) (string, error) {
4646
return string(buf), nil
4747
}
4848

49-
func fileExists(fileName string) (bool, error) {
49+
func fileExists(fileName string) bool {
5050

5151
_, err := os.Stat(fileName)
52-
53-
if err == nil {
54-
return true, nil
55-
}
56-
57-
if os.IsNotExist(err) {
58-
return false, nil
59-
}
60-
61-
return true, err
52+
return !os.IsNotExist(err)
6253
}
6354

6455
func writeToFile(fileName string, content string) error {
@@ -87,28 +78,13 @@ func appendToFile(fileName string, content string) error {
8778
return err
8879
}
8980

90-
func linkFile(fileName string, fileTo string) error {
91-
92-
exists, err := fileExists(fileTo)
81+
func linkFile(fileFrom string, fileTo string) error {
9382

94-
if err != nil {
95-
return err
96-
}
97-
98-
if exists {
83+
if fileExists(fileTo) {
9984
return nil
10085
}
10186

102-
command := ExecCommand{
103-
Command: "ln",
104-
Args: []string{
105-
"-s",
106-
fileName,
107-
fileTo,
108-
},
109-
}
110-
111-
return runCommand(command)
87+
return os.Link(fileFrom, fileTo)
11288
}
11389

11490
func runCommand(execCommad ExecCommand) error {

0 commit comments

Comments
 (0)