mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Allow chaining of FileSystem methods
This commit is contained in:
parent
2e1be45957
commit
efcd71b296
1 changed files with 6 additions and 3 deletions
|
@ -10,23 +10,25 @@ type FileSystem struct {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
_, err := os.Stat(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
|
||||
func (self *FileSystem) PathNotPresent(path string) {
|
||||
func (self *FileSystem) PathNotPresent(path string) *FileSystem {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
_, err := os.Stat(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
|
||||
func (self *FileSystem) FileContent(path string, matcher *TextMatcher) {
|
||||
func (self *FileSystem) FileContent(path string, matcher *TextMatcher) *FileSystem {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
_, err := os.Stat(path)
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -46,4 +48,5 @@ func (self *FileSystem) FileContent(path string, matcher *TextMatcher) {
|
|||
|
||||
return true, ""
|
||||
})
|
||||
return self
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue