Skip to content

Commit

Permalink
add logic to handle for f.Close()
Browse files Browse the repository at this point in the history
Signed-off-by: xin.li <xin.li@daocloud.io>
  • Loading branch information
my-git9 committed Jul 15, 2022
1 parent 7d31d61 commit a1b4e85
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/e2e/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ func init() {
panic(fmt.Sprintf("Could not read record file %s: %v", rf, err))
}
}
defer f.Close()
defer func() {
err := f.Close()
if err != nil {
panic(fmt.Sprintf("Could not close record file %s: %v", rf, err))
}
}()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
testsRun[scanner.Text()] = true
Expand Down Expand Up @@ -840,7 +845,12 @@ func RecordTestRun(t *testing.T) {
if err != nil {
t.Fatalf("could not open record file %s: %v", rf, err)
}
defer f.Close()
defer func() {
err := f.Close()
if err != nil {
t.Fatalf("could not close record file %s: %v", rf, err)
}
}()
if _, err := f.WriteString(fmt.Sprintf("%s\n", t.Name())); err != nil {
t.Fatalf("could not write to %s: %v", rf, err)
}
Expand Down

0 comments on commit a1b4e85

Please sign in to comment.