when the file that was opened has been read into buffer, the file should be close.
Signed-off-by: Mabin <bin.ma@huawei.com> Upstream-commit: d5ea4bae4a15cc9f3c16c046389737682277ff0f Component: engine
This commit is contained in:
@@ -851,14 +851,11 @@ func writeFile(dst, content string, t *testing.T) {
|
||||
// Return the contents of file at path `src`.
|
||||
// Call t.Fatal() at the first error (including if the file doesn't exist)
|
||||
func readFile(src string, t *testing.T) (content string) {
|
||||
f, err := os.Open(src)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, err := ioutil.ReadAll(f)
|
||||
data, err := ioutil.ReadFile(src)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
return string(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user