mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
migrate discard staged changes test
This commit is contained in:
@ -24,3 +24,26 @@ func (self *FileSystem) PathNotPresent(path string) {
|
||||
return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
||||
})
|
||||
}
|
||||
|
||||
// Asserts that the file at the given path has the given content
|
||||
func (self *FileSystem) FileContainsContent(path string, matcher *matcher) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
_, err := os.Stat(path)
|
||||
if os.IsNotExist(err) {
|
||||
return false, fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
||||
}
|
||||
|
||||
output, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return false, fmt.Sprintf("Expected error when reading file content at path '%s': %s", path, err.Error())
|
||||
}
|
||||
|
||||
strOutput := string(output)
|
||||
|
||||
if ok, errMsg := matcher.context("").test(strOutput); !ok {
|
||||
return false, fmt.Sprintf("Unexpected content in file %s: %s", path, errMsg)
|
||||
}
|
||||
|
||||
return true, ""
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user