mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Allow chaining of FileSystem methods
This commit is contained in:
@ -10,23 +10,25 @@ type FileSystem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This does _not_ check the files panel, it actually checks the filesystem
|
// This does _not_ check the files panel, it actually checks the filesystem
|
||||||
func (self *FileSystem) PathPresent(path string) {
|
func (self *FileSystem) PathPresent(path string) *FileSystem {
|
||||||
self.assertWithRetries(func() (bool, string) {
|
self.assertWithRetries(func() (bool, string) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
return err == nil, fmt.Sprintf("Expected path '%s' to exist, but it does not", path)
|
return err == nil, fmt.Sprintf("Expected path '%s' to exist, but it does not", path)
|
||||||
})
|
})
|
||||||
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
// This does _not_ check the files panel, it actually checks the filesystem
|
// This does _not_ check the files panel, it actually checks the filesystem
|
||||||
func (self *FileSystem) PathNotPresent(path string) {
|
func (self *FileSystem) PathNotPresent(path string) *FileSystem {
|
||||||
self.assertWithRetries(func() (bool, string) {
|
self.assertWithRetries(func() (bool, string) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
||||||
})
|
})
|
||||||
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asserts that the file at the given path has the given content
|
// Asserts that the file at the given path has the given content
|
||||||
func (self *FileSystem) FileContent(path string, matcher *TextMatcher) {
|
func (self *FileSystem) FileContent(path string, matcher *TextMatcher) *FileSystem {
|
||||||
self.assertWithRetries(func() (bool, string) {
|
self.assertWithRetries(func() (bool, string) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
@ -46,4 +48,5 @@ func (self *FileSystem) FileContent(path string, matcher *TextMatcher) {
|
|||||||
|
|
||||||
return true, ""
|
return true, ""
|
||||||
})
|
})
|
||||||
|
return self
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user