0

I can write a normal gzip file:

var b bytes.Buffer
w := gzip.NewWriter(&b)
w.Write([]byte("hello, world\n"))
w.Close()

But I cannot figure out how to mock a gzip file so that I can read that mocked file for my tests:

afero.WriteFile(mfs, "/path/to/file.gz", []byte("here is file"), 0644)

If I try to read this mock gzip file the error I get is:

gzip: invalid header
user_78361084
  • 3,538
  • 22
  • 85
  • 147

0 Answers0