MCPcopy
hub / github.com/perkeep/perkeep / checkOpen

Function checkOpen

internal/osutil/paths_test.go:45–65  ·  view source on GitHub ↗

Calls OpenCamliInclude to open path, and checks that it contains "test"

(t *testing.T, path string)

Source from the content-addressed store, hash-verified

43
44// Calls OpenCamliInclude to open path, and checks that it contains "test"
45func checkOpen(t *testing.T, path string) {
46 found, e := findCamliInclude(path)
47 if e != nil {
48 t.Errorf("Failed to find %v", path)
49 return
50 }
51 var file *os.File
52 file, e = os.Open(found)
53 if e != nil {
54 t.Errorf("Failed to open %v", path)
55 } else {
56 var d [10]byte
57 if n, _ := file.Read(d[:]); n != 4 {
58 t.Errorf("Read incorrect number of chars from test.config, wrong file?")
59 }
60 if string(d[0:4]) != "test" {
61 t.Errorf("Wrong test file content: %v", string(d[0:4]))
62 }
63 file.Close()
64 }
65}
66
67// Test for error when file doesn't exist
68func TestOpenCamliIncludeNoFile(t *testing.T) {

Callers 3

TestOpenCamliIncludeCWDFunction · 0.85
TestOpenCamliIncludeDirFunction · 0.85
TestOpenCamliIncludePathFunction · 0.85

Calls 4

findCamliIncludeFunction · 0.85
OpenMethod · 0.65
CloseMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected