mirror of
https://github.com/kairos-io/kcrypt.git
synced 2025-08-19 15:57:28 +00:00
Don't hide there error when it's not about file not existing
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
7d077c9353
commit
bb144f204a
@ -127,6 +127,8 @@ func createInfoFileIfNotExists(fileName string) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
} else if err != nil {
|
||||||
|
return false, err
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,17 @@ var _ = Describe("Partition Info file parsing", func() {
|
|||||||
fmt.Sprintf("partition-info-%d.yaml", time.Now().UnixNano()))
|
fmt.Sprintf("partition-info-%d.yaml", time.Now().UnixNano()))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
When("there is some error other than the file doesn't exist", func() {
|
||||||
|
It("returns 'false' and the error", func() {
|
||||||
|
// We are trying to write to a path that doesn't exist (not the file, the path).
|
||||||
|
// https://stackoverflow.com/a/66808328
|
||||||
|
fileName = "\000x"
|
||||||
|
_, _, err := pi.NewPartitionInfoFromFile(fileName)
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err.Error()).To(ContainSubstring("stat \000x: invalid argument"))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
It("creates the file and returns 'false' and a non nil mapping", func() {
|
It("creates the file and returns 'false' and a non nil mapping", func() {
|
||||||
result, existed, err := pi.NewPartitionInfoFromFile(fileName)
|
result, existed, err := pi.NewPartitionInfoFromFile(fileName)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Loading…
Reference in New Issue
Block a user