refactor: move common io-related functions into new file

This commit is contained in:
Jose Diaz-Gonzalez
2020-10-10 19:15:55 -04:00
committed by Jose Diaz-Gonzalez
parent 696df45306
commit 33d3722060
5 changed files with 224 additions and 147 deletions

28
plugins/common/io_test.go Normal file
View File

@@ -0,0 +1,28 @@
import "testing"
func TestCommonFileToSlice(t *testing.T) {
RegisterTestingT(t)
Expect(setupTestApp()).To(Succeed())
lines, err := FileToSlice(testEnvFile)
Expect(err).NotTo(HaveOccurred())
Expect(lines).To(Equal([]string{testEnvLine}))
teardownTestApp()
}
func TestCommonFileExists(t *testing.T) {
RegisterTestingT(t)
Expect(setupTestApp()).To(Succeed())
Expect(FileExists(testEnvFile)).To(BeTrue())
teardownTestApp()
}
func TestCommonReadFirstLine(t *testing.T) {
RegisterTestingT(t)
line := ReadFirstLine(testEnvFile)
Expect(line).To(Equal(""))
Expect(setupTestApp()).To(Succeed())
line = ReadFirstLine(testEnvFile)
Expect(line).To(Equal(testEnvLine))
teardownTestApp()
}