func brokenCallWriteFile(filename string, data []byte) error { f, err := mockOS.Create(filename) if err != nil { return err } defer errors.AppendCall(&err, f.Close) n, err := f.Write(data) if err == nil && n < len(data) { err = io.ErrShortWrite } return err }
func ReinventTheIOUtil(filename string) (buf []byte, err error) { f, err := os.Open(filename) if err != nil { return nil, err } defer errors.AppendCall(&err, f.Close) buf, err = ioutil.ReadAll(f) if err != nil { return nil, err } return buf, nil }