test: improve reliability of file operations

- Add error handling after writing to a file in `local_file_test.go` test function

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2024-02-17 16:26:13 +08:00
parent acf41a9a1a
commit e3221e7a7a
No known key found for this signature in database
1 changed files with 4 additions and 1 deletions

View File

@ -18,7 +18,10 @@ func TestLocalFile(t *testing.T) {
t.Error(err) t.Error(err)
} }
defer os.Remove(f.Name()) defer os.Remove(f.Name())
f.WriteString("Gin Web Framework") _, err = f.WriteString("Gin Web Framework")
if err != nil {
t.Error(err)
}
f.Close() f.Close()
dir, filename := filepath.Split(f.Name()) dir, filename := filepath.Split(f.Name())