MCPcopy
hub / github.com/jesseduffield/lazygit / FileContent

Method FileContent

pkg/integration/components/file_system.go:31–52  ·  view source on GitHub ↗

Asserts that the file at the given path has the given content

(path string, matcher *TextMatcher)

Source from the content-addressed store, hash-verified

29
30// Asserts that the file at the given path has the given content
31func (self *FileSystem) FileContent(path string, matcher *TextMatcher) *FileSystem {
32 self.assertWithRetries(func() (bool, string) {
33 _, err := os.Stat(path)
34 if os.IsNotExist(err) {
35 return false, fmt.Sprintf("Expected path '%s' to exist, but it does not", path)
36 }
37
38 output, err := os.ReadFile(path)
39 if err != nil {
40 return false, fmt.Sprintf("Expected error when reading file content at path '%s': %s", path, err.Error())
41 }
42
43 strOutput := string(output)
44
45 if ok, errMsg := matcher.context("").test(strOutput); !ok {
46 return false, fmt.Sprintf("Unexpected content in file %s: %s", path, errMsg)
47 }
48
49 return true, ""
50 })
51 return self
52}

Calls 5

assertWithRetriesMethod · 0.80
testMethod · 0.80
SprintfMethod · 0.65
ErrorMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected