gfile is an implementation of gbytes' BufferProvider interface that allows you to make assertions on the contents of files as they are updated using the ginkgo testing framework.
go get github.com/BooleanCat/gfile
Below is an example usage of gfile.Buffer
to check that a logfile has had a
specific message written to it.
...
Context("when writing to a log file", func() {
var (
buffer *gfile.Buffer
err error
)
BeforeEach(func() {
buffer, err = gfile.NewBuffer("/tmp/foo")
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
err := buffer.Close()
Expect(err).NotTo(HaveOccurred())
})
It("can be read back", func() {
WriteToLog("/tmp/foo")
Eventually(buffer).Should(gbytes.Say("I'm a log message"))
})
})
...